Hi there
This question is based on MySQL, using the ADODB abstraction layer (and I'm kind of new to transactions).
I'm just wondering about how transactions work with multiple INSERT statements, where inserted records reference previously inserted records.
For example:
I have 2 tables -
people (
id (primary, auto_increment),
full_name,
email,
photograph
)
photographs (
id (primary, auto_increment),
filename
)
people.photograph corresponds to photographs.id
A new profile is inserted from one page, which includes field entry for:
people.full_name
people.email
photographs.filename
Normally what I do without transactions is initialise an ADODB connection object ($conn), insert the photograph in one statement, then insert the person in the next, using $conn->InsertID() for the photograph field.
It would be mighty handy to use transactions on such a query set, in the event that for some reason the person record fails to insert.
Would it howerver be possible to do using transactions, given that in the time between the photograph being added and its id being assigned to people.photograph, a second transaction instance could have been committed, throwing people.photograph in the first transaction instance out by one?
Any remarks / comments appreciated.
This question is based on MySQL, using the ADODB abstraction layer (and I'm kind of new to transactions).
I'm just wondering about how transactions work with multiple INSERT statements, where inserted records reference previously inserted records.
For example:
I have 2 tables -
people (
id (primary, auto_increment),
full_name,
email,
photograph
)
photographs (
id (primary, auto_increment),
filename
)
people.photograph corresponds to photographs.id
A new profile is inserted from one page, which includes field entry for:
people.full_name
people.email
photographs.filename
Normally what I do without transactions is initialise an ADODB connection object ($conn), insert the photograph in one statement, then insert the person in the next, using $conn->InsertID() for the photograph field.
It would be mighty handy to use transactions on such a query set, in the event that for some reason the person record fails to insert.
Would it howerver be possible to do using transactions, given that in the time between the photograph being added and its id being assigned to people.photograph, a second transaction instance could have been committed, throwing people.photograph in the first transaction instance out by one?
Any remarks / comments appreciated.