|
-
Jun 25th, 2008, 03:59 AM
#1
Thread Starter
Frenzied Member
How reliable is mysqli_insert_id?
The mysqli_insert_id() function returns the ID generated by a query on a table with a column having the AUTO_INCREMENT attribute. If the last query wasn't an INSERT or UPDATE statement or if the modified table does not have a column with the AUTO_INCREMENT attribute, this function will return zero.
What if you did an insert or update that failed?
What I'm doing is looping through a LOT of records, taking the values I get, modify it and insert into another table.
At the moment I rely on mysqli_insert_id to see if the insert was successful, but what if the insert failed for whatever reason? Will mysqli_insert_id return 0 or still hold the id of the last successful insert?
I cannot really check if the insert was performed by doing a query as there will be records (say cities) that will be duplicate (as more than one country have the same city).
Last edited by StrangerInBeijing; Jun 26th, 2008 at 08:06 PM.
Reason: Resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|