2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: edit_hostnames_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
13 open Cocanwiki_template
15 let template = get_template "admin/edit_hostnames_form.html"
17 let run r (q : cgi) (dbh : Dbi.connection) _ _ =
18 let hostid = int_of_string (q#param "hostid") in
20 template#set "id" (string_of_int hostid);
22 let sth = dbh#prepare_cached
23 "select canonical_hostname from hosts where id = ?" in
24 sth#execute [`Int hostid];
26 let canonical_hostname = sth#fetch1string () in
27 template#set "canonical_hostname" canonical_hostname;
29 let sth = dbh#prepare_cached "select name from hostnames
32 sth#execute [`Int hostid; `String canonical_hostname];
34 let hostnames = sth#map (function [`String hostname] -> hostname
35 | _ -> assert false) in
36 template#set "hostnames" (String.concat "\n" hostnames);