Open tmblog opened 5 years ago
How can I get the last ID using a transaction?
$db->startTransaction(); ... if (!$db->insert('myTable', $insertData)) { //Error while saving, cancel new record $db->rollback(); } else { //OK $db->commit(); }
If I do: $id = $db->insert('myTable', $insertData) I get duplicate inserts
$id = $db->insert('myTable', $insertData)
How can I get the last ID using a transaction?
$db->startTransaction(); ... if (!$db->insert('myTable', $insertData)) { //Error while saving, cancel new record $db->rollback(); } else { //OK $db->commit(); }
If I do:
$id = $db->insert('myTable', $insertData)
I get duplicate inserts