Re: mysql_insert_id() vs. last_insert_id()
| From: | Randy Phillips | Date: | Wed, 29 Jan 2003 14:29:48 +0000 |
| Subject: | Re: mysql_insert_id() vs. last_insert_id() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25226@lists.php.net to get a copy of this message | ||
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