Saturday, 15 March 2014

php - Next id, future Id, -



php - Next id, future Id, -

this question has reply here:

most efficient way table row count 11 answers (mysql, php) how auto_increment field value before inserting data? 10 answers

using php , mysql, want number of future id in mysql, number after, nextincrement. how can that?

it not possible reliably. can select max(id)+1, that'll fail if you've got rolled-back transactions and/or parallel processes running.

the best method is:

start transaction. insert skeleton record , select last_insert_id() id use id child/parallel record updates populate skeleton record else need commit transaction.

if stage fails, roll transaction, , throw away id, because it's invalid , never used again.

php mysql phpmyadmin

No comments:

Post a Comment