I am using ADODB to connect to my database. After I submit the query I want to get the ID of the last inserted row (from the query just inserted).
ADODB has an Insert_ID() function that should retrieve this is but it is not...
db->Insert_ID()
is not working, neither is
db->Insert_ID($table, $key)
They both just return empty values. I doubled checked my table and the insert statement is indeed working, a new row is being put in, and the key is auto_increment. Am I using the Insert_ID wrong or is there a better way to retrieve the key of the last row inserted?
Thanks
Edit: Adding code
$result = \PSU::db->Execute( $updateSQL, $values_array );
$id = \PSU::db->Insert_ID();
// $id = \PSU::db->Insert_ID( $table, $key );
\PSU::db is our ADODB implementation class, taking care of things like connecting, disconnecting, etc.
Is it possible that you are disconnecting and reconnecting to mysql between the query and the insert_id()?