Scripts updated to use new PG interface.
[cocanwiki.git] / scripts / set_password_form.ml
index 5f884b8..99a309d 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: set_password_form.ml,v 1.1 2004/09/21 13:01:16 rich Exp $
+ * $Id: set_password_form.ml,v 1.3 2006/03/28 16:24:08 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,18 +27,18 @@ open Printf
 open Cocanwiki
 open Cocanwiki_template
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+let run r (q : cgi) dbh hostid _ _ =
   let template = get_template dbh hostid "set_password_form.html" in
 
-  let userid = int_of_string (q#param "userid") in
+  let userid = Int32.of_string (q#param "userid") in
 
-  let sth = dbh#prepare_cached "select name from users
-                                 where id = ? and hostid = ?" in
-  sth#execute [`Int userid; `Int hostid];
+  let username = List.hd (
+    PGSQL(dbh)
+      "select name from users
+        where id = $userid and hostid = $hostid"
+  ) in
 
-  let username = sth#fetch1string () in
-
-  template#set "userid" (string_of_int userid);
+  template#set "userid" (Int32.to_string userid);
   template#set "username" username;
 
   q#template template