$sql='INSERT INTO complaints(complaint_id) values(default)';
$db->query($sql,array());
//get newly added complaint_id
$complaint_id=$db->lastInsertId();
I used above code to get last insert ID from complaints table. But it gives an error like
Fatal error: Call to undefined method EMMACore\Utils\DBConnection::lastInsertId() in /h... Can anybody tell me what is wrong in my application.Thanks.
In most case, the PDO instance is a property of
EMMACore\Utils\DBConnection, so check the source code and find it out.Something like:
$db->getDbh()->lastInsertId();wheregetDbh(or something like that) returns the PDO instance.Edit: After seeing your result of
var_dump(), that is for sure.