- let sth = dbh#prepare_cached "select id from users
- where hostid = ? and name = ?" in
- sth#execute [`Int hostid; `String username];
-
- (try
- sth#fetch1 ();
- error ~back_button:true ~title:"Username already taken"
- q ("Someone, possibly you, has already taken that username. " ^
- "If you think you have forgotten your password, try going back " ^
- "and clicking on the 'Forgotten your password?' link.");
- return ()
- with
- Not_found -> ());
+ let rows = PGSQL(dbh)
+ "select id from users where hostid = $hostid and name = $username" in
+
+ (match rows with
+ | [_] ->
+ error ~back_button:true ~title:"Username already taken"
+ dbh hostid q
+ ("Someone, possibly you, has already taken that username. " ^
+ "If you think you have forgotten your password, try going back " ^
+ "and clicking on the 'Forgotten your password?' link.");
+ return ()
+ | [] -> ()
+ | _ -> assert false
+ );