(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page_email_confirm.ml,v 1.4 2006/03/27 18:09:46 rich Exp $
+ * $Id: page_email_confirm.ml,v 1.5 2006/03/28 16:24:07 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
let pending = q#param "p" in
(* Get the relevant fields from the database. *)
- let sth = dbh#prepare_cached "select url, email from page_emails
- where hostid = ? and pending = ?" in
- sth#execute [Some hostid; Some pending];
+ let rows = PGSQL(dbh) "select url, email from page_emails
+ where hostid = $hostid and pending = $pending" in
let page, email =
- try
- (match sth#fetch1 () with
- [ Some page; Some email ] -> page, email
- | _ -> assert false)
- 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
+ | [ row ] -> row
+ | [] ->
+ 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 page_emails set pending = null
- where hostid = ? and pending = ?" in
- sth#execute [Some hostid; Some pending];
+ PGSQL(dbh) "update page_emails set pending = null
+ where hostid = $hostid and pending = $pending";
PGOCaml.commit dbh;