[drupal-devel] LOCK vs. SELECT FOR UPDATE
piotrwww at krukowiecki.net
piotrwww at krukowiecki.net
Tue Oct 18 14:20:43 UTC 2005
On Tue, Oct 18, 2005 at 09:32:55AM -0400, Khalid B wrote:
> Here is a workaround that someone cooked up to get over the fact that
> his host does not allow for LOCK TABLE privilege.
>
> http://drupal.org/node/34455
if(!db_affected_rows($result)) {
db_query("insert into {sequences} (id, name) values (0, '%s')", $name);
db_query("update {sequences} set id = last_insert_id(id+1) where name =
'%s'", $name);
}
How is it atomic? It can insert to (0, $name) rows into the table
> Is this something we can go by?
Dunno. ;)
--
Piotrek
irc: #debian.pl
Mors Drosophilis melanogastribus!
More information about the drupal-devel
mailing list