I'm inserting a record using PDO and saving the result in $result
which I use as a boolean
$result = $addRecord->execute();
if ($result){
//add successful
} else {
//add unsuccessful
}
I'd like to also get the record id
just added. In the table, each record has an auto_incremented
field called id
. I tried doing this
$new_id = $result['id'];
but it seems $result
doesn't actually hold the record added. Can someone confirm this and how would I then access the record just added?
Note that several people may be adding to the same table at the same time, so I need something really accurate.