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,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
                            (53kr33t w0rdz: sql table query)


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to