Don Read wrote:
On 18-Jun-2003 Jonas Geiregat wrote:
I'm using php + mysql for my project
I want to get the last insert ID.
I could use the php function mysql_last_id();
but I could aslo use @@identity.
Now some people have advised me NOT to use @@identity, cause it's not
save buggy sometimes slow ..
is this true am I better of with the php function ?
Don't use either one.
PHP's mysql_last_id() is stored as a _long; it'll break on BIGINT ids.
If you need to keep the value in a PHP variable, use
'SELECT LAST_INSERT_ID() as id', and retrive it as a string.
also I do my query insert something
after that query I do an other query to get the last insert ID,
if someone else does a insert query between those 2 query's won't that
affect my last insert ID and won't I get the wrong one ?
No. The id is per connection.
The return value is the last insert performed by your connection.
Regards,
Why did they make select @@identity then ?
Is it just cause most other db's have this thing ?
and what's the difference between @@identity and select last_insert_id() ?
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]