$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();
where getDbh
(or something like that) returns the PDO instance.
Edit: After seeing your result of var_dump()
, that is for sure.
class db extends PDO
例如,您可以参考此链接PHP PDO Wrapper Class 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.