Reputation: 2113
I have this code
if($pdo instanceof PDO){
$this->last = 'lastInsertId';
}
else{
$this->last = 'insert_id';
}
When i do the insert query in the datebase, how can i get the last inserted ID. I tried like this
$this->db->{$this->last};
But it did not work.
Thanks for the help in advance.
Upvotes: 0
Views: 63
Reputation: 2412
lastInsertId
is a method, therefore you should call it as a method, not as a property/field.
$this->db->{$this->last}();
Upvotes: 3