Re: DB.php version of mysql_insert_id()
| From: | Hodicska Gergely | Date: | Thu, 18 Dec 2003 22:08:34 +0000 |
| Subject: | Re: DB.php version of mysql_insert_id() | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9690@lists.php.net to get a copy of this message | ||
Hi!
Torsten Roehr wrote:
use the ID afterwards for inserts in other tables. This is much safer than mysql_insert_id() because there could have been another insert between the first insert and the mysql_insert_id() call. See the documentation for howFrom the mysql manual: The last ID that was generated is maintained in the server on a per-connection basis. This means the value the function returns to a given client is the most recent AUTO_INCREMENT value generated by that client. The value cannot be affected by other clients, even if they generate AUTO_INCREMENT values of their own. This behavior ensures that you can retrieve your own ID without concern for the activity of other clients, and without the need for locks or transactions. Felho