Changes done on the Mac.
[cocanwiki.git] / scripts / mailing_list_confirm.ml
index 1ed1f85..d7b7316 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: mailing_list_confirm.ml,v 1.5 2006/03/27 18:09:46 rich Exp $
+ * $Id: mailing_list_confirm.ml,v 1.6 2006/03/28 13:20:00 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
@@ -31,24 +31,22 @@ let run r (q : cgi) dbh hostid _ _ =
   let pending = q#param "p" in
 
   (* Get the relevant fields from the database. *)
-  let sth = dbh#prepare_cached "select email from mailing_lists
-                                 where hostid = ? and pending = ?" in
-  sth#execute [Some hostid; Some pending];
+  let rows = PGSQL(dbh) "select email from mailing_lists
+                          where hostid = $hostid and pending = $pending" in
 
   let email =
-    try
-      sth#fetch1string ()
-    with
-       Not_found ->
-         error ~close_button:true ~title:"Email already confirmed"
-           dbh hostid q
-           "It looks like that email address has already been confirmed.";
-         return () in
+    match rows with
+    | [email] -> email
+    | [] ->
+       error ~close_button:true ~title:"Email already confirmed"
+         dbh hostid q
+         "It looks like that email address has already been confirmed.";
+       return ()
+    | _ -> assert false in
 
   (* Update the database. *)
-  let sth = dbh#prepare_cached "update mailing_lists set pending = null
-                                 where hostid = ? and pending = ?" in
-  sth#execute [Some hostid; Some pending];
+  PGSQL(dbh) "update mailing_lists set pending = null
+               where hostid = $hostid and pending = $pending";
 
   PGOCaml.commit dbh;