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

[eluser]TheFuzzy0ne[/eluser]
OK. Imagine this...

You drive to a car park, park your car, and then go to the ticket machine to purchase a ticket for the time your car is going to be there. How can you be sure you're not getting someone else's ticket? Quite simply, because each transaction is handled individually. The ticket is printed there and then, and is unique to you.

When the row is inserted, an ID is given to it. The ID will never change unless you change it manually.

An insert is only a single action. A transaction in database terms consists of more than one action, that depend on each other in some way.

I think I know what you're getting at, and the answer to that is also simple. When you make a connection to the database, the connection is given a unique ID by the database. That means that any connection-specific data (such as insert_id()), is specific to that particular connection ID. Once the connection is finished, the connection specific data is also done. It's a lot like a PHP session, only the session is cleared as soon as the connection is closed.

Hope this helps.


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



Theme © iAndrew 2016 - Forum software by © MyBB