Re: mysql_insert_id() (was: MySQL <-> Oracle8)
| From: | Paul DuBois | Date: | Wed, 07 Jun 2000 13:28:44 +0000 |
| Subject: | Re: mysql_insert_id() (was: MySQL <-> Oracle8) | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1204@lists.php.net to get a copy of this message | ||
At 11:30 PM +0200 06-05-2000, Dieter Kneffel wrote:
Ryan Adams schrieb:If the row is inserted by another client, you'll still get back the id for the row you inserted. If you insert another row yourself, you'll get back the id for the most recently-inserted row, of course. In other words, mysql_insert_id() is client-specific; its value cannot be affected by the activity of other clients. However, one thing you should be aware of is that the value it returns is reset for EVERY query, not just INSERT queries. If you do an INSERT, then a SELECT, then call mysql_insert_id(), you'll get back a 0 value. Therefore you should call mysql_insert_id() right after you insert the row and save the value. So -- Paul DuBois, paul@snake.netOn Mon, Jun 05, 2000 at 08:03:29PM +0200, Dieter Kneffel wrote:Looks like a good idea, basically. But what happens, if there is high load on the server and a new entry is inserted into the table between my previous insert and this query?Hmm. I would guess that this is an issue with mysql_insert_id() as well.Can someone confirm this issue? Is the mysql_insert_id() funktion safe or is this a possible problem that has to be taken care of?