我想检索数据库中插入行的 id,但我不知道该怎么做。
我尝试使用 SQL 子句 RETURNING id
返回,但不起作用。
插入一行后如何返回id?
最佳答案
在 Prepared Statement 上调用 execute()
方法后,插入行的 id 将在 insert_id
属性中。
$pstm->execute();
$pstm->insert_id;
关于php - 使用 Prepared Statement,我如何返回插入行的 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6556720/