Date: 02/28/00
- Next message: Thomas Flemming: "[PHPLIB] "Phplib for Java.""
- Previous message: Alan Meadows: "[PHPLIB] Logout issues..."
- In reply to: Shandy Brown: "[PHPLIB] Atomicity"
- Next in thread: Kristian Koehntopp: "Re: [PHPLIB] Atomicity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I am not sure if this helps you, but I had the problem of missing
transactions when adding users.
You can not first check if a username already exists (SELECT) and then if
not add it (UPDATE) without having the very small risk - so difficult to
find error - on an duplicate username.
I solved it by using INSERT and handling the error (raised if name is not
unique), with a bit of code like:
$old_halt = $auth->db->Halt_On_Error;
$auth->db->Halt_On_Error = "no";
$query = sprintf( "insert %s set username='%s', password='%s',
user_id='%s';",
$auth->database_table, addslashes($my_username),
addslashes($my_password), $uid);
$auth->db->query( $query);
$auth->db->Halt_On_Error = $old_halt;
if ($auth->db->Errno || $auth->db->affected_rows() == 0)
return "username in use, bla bla";
Greetings
Jeroen.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Jeroen Laarhoven, Zwolle, Netherlands
email: jeroen <email protected>
www: http://jeroen.polder.net
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
----- Original Message -----
From: Shandy Brown <shandyb <email protected>>
To: <phplib <email protected>>
Sent: maandag 28 februari 2000 18:30
Subject: [PHPLIB] Atomicity
> Does anyone know a good way to do an atomic transaction with PHP/MySQL?
>
> I'm using PHPLIB, so if it could be done using a DB class that'd be a
bonus.
>
> basically, I have to check if there's room in a queue (a SELECT statement)
and
> if there is (check done in PHP), add the user to the queue (an UPDATE
> statement).
>
> So if customer B did the SELECT statement before customer A had a chance
to do
> an UPDATE, they could both be added to the queue, thus overflowing it.
>
> -shandy
>
> --
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Shandy Brown (http://sjbrown.geeky.net)
> Inline Internet Systems (http://www.inline.net)
>
> iHTML (http://www.ihtml.com)
> iHTML Merchant (http://www.ihtmlmerchant.com)
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> -
> PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
> To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
> the body, not the subject, of your message.
>
>
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.
- Next message: Thomas Flemming: "[PHPLIB] "Phplib for Java.""
- Previous message: Alan Meadows: "[PHPLIB] Logout issues..."
- In reply to: Shandy Brown: "[PHPLIB] Atomicity"
- Next in thread: Kristian Koehntopp: "Re: [PHPLIB] Atomicity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

