Re: mysql_insert_id() vs. last_insert_id()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



on 1/28/03 11:42 AM, John W. Holmes at holmes072000@charter.net wrote:

>> The reason I ask is, if you use mysql_insert_id() on a busy server and
> it
>> does not function on a per-connection basis, don't you run the risk of
>> getting the last ID of somebody else's INSERT query on the server?
> 
> Yes, they are both on a per-connection basis. They'd be useless
> otherwise.


I agree. Although, the MySQL docs are confusing on the distinction between
these two functions in my opinion.

The one thing that jumps out at me is that if you insert multiple
rows at the same time with an insert statement, LAST_INSERT_ID() returns the
value for the first inserted row only, whereas MYSQL_INSERT_ID() returns the
last id inserted. Am I reading that right?

I guess the question is: Why is it useful to only store the first id? When
would you want that?


----------------------------------------------------------------------
Randy Phillips                                     www.phillips-it.com
phillipsIT, L.L.C.                                 voice: 636.390.9468
Senior Web Developer                                eFax: 501.423.3817
----------------------------------------------------------------------
   Get SideKick -> for MySQL -> http://www.phillips-it.com/sidekick


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux