Welcome Guest, Not a member yet? Register   Sign In
Parallel INSERT operations possible conflicts using "$this->db->insert_id()"?
#10

[eluser]TheFuzzy0ne[/eluser]
There's no such thing as a "permanent" connection. Persistent, yes, but with a persistent connection db_insert_id() will still return the ID of the last row inserted via that connection ID. If you insert 10 rows, you will only get the ID of the last row that was inserted by that connection.

If another process was inserting rows at the same time, db_insert_id() would return the ID of the last row that was inserted by that connection. Database connections are isolated from one another.

Remember, db_insert_id() only returns the ID of the last row inserted with that connection, it is unaware of any other database connections. The purpose of db_insert_id() is to get the ID of a row that's just been inserted. It would be useless if, on a busy site, it started handing out insert IDs for other rows. I use it every day, and millions of other developers do too, and they don't have any problems with it.


Messages In This Thread
Parallel INSERT operations possible conflicts using "$this->db->insert_id()"? - by El Forum - 02-09-2009, 04:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB