From: Miguel Angel Blanch Lardin <miguelangelblanchlardin@ho...> - 2004-09-01 22:49:16
I am having problems with the SQL code for multizones.
On the new code, we store RPObjects into the database *BUT* the object_id is
not longer the id of the RPObject, but a database rpobject id, that means
that it only makes sense inside database.
The problem is how to get that ids? An auto_increment column won't work as
there is no way to query the object for its object_id.
My (actual) idea is to create a new table and store there the latest
assigned object_id. This method has the drawback of having to lock the table
to get the id.
Miguel -dizzy programer-
Tired of spam? Get advanced junk mail protection with MSN 8.
From: Grzegorz Sobanski <silk@po...> - 2004-09-03 20:24:34
* Miguel Angel Blanch Lardin <miguelangelblanchlardin@...> [2004-=
> The problem is how to get that ids? An auto_increment column won't work=
> there is no way to query the object for its object_id.
I'm not 100% sure if I understood correctly, but
If column is auto_increment and you insert a row, then you can get the
value that this column got.
You can use LAST_INSERT_ID() SQL function or the mysql_insert_id() C API
function. They returns most recent AUTO_INCREMENT value.
They are connection-specific so are not affected by other inserts.
Hope that helps.
Grzegorz "Silk" Soba=F1ski silk (at) poznan.telbank.pl
An algorithm must be seen to be believed.
-- D.E. Knuth