Hi,
i have the following problem:
i have 2 tables,
the first one has an ID as primary key (auto increment).
The second one has this ID as foreign key.
No if i want to add data, i write the data in the first table
(with the ID as primary key), then the db will add a new entry
with ID+1 as IDs value. (auto_increment)
Now the next step is to save the rest into the other table
with this new ID as key.
So i have to read the new ID first, before writing it in the second table.
BUT WHAT HAPPENS IF ANOTHER CLIENT WRITES INTO THE FIRST TABLE BETWEEN MY INSERT AND SELECT ???
Then i would read (the new) WRONG ID ???
I know i can lock the table, but this isn't whery fine, so is there a better solution ?
Please help,
phrazer
i have the following problem:
i have 2 tables,
the first one has an ID as primary key (auto increment).
The second one has this ID as foreign key.
No if i want to add data, i write the data in the first table
(with the ID as primary key), then the db will add a new entry
with ID+1 as IDs value. (auto_increment)
Now the next step is to save the rest into the other table
with this new ID as key.
So i have to read the new ID first, before writing it in the second table.
BUT WHAT HAPPENS IF ANOTHER CLIENT WRITES INTO THE FIRST TABLE BETWEEN MY INSERT AND SELECT ???
Then i would read (the new) WRONG ID ???
I know i can lock the table, but this isn't whery fine, so is there a better solution ?
Please help,
phrazer