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