0

尝试使用以下行获取最后插入的 id: $db->insert_id;

但它在最新版本的 ezsql 中不返回任何内容。

4

2 回答 2

1

使用 select 获取最后一个 id 可能有效,但并非总是如此。如果 2 个或更多用户同时插入,您可能无法获得正确的 id。$db->insert_id已被替换为$db->getInsert_Id()

于 2021-02-14T17:57:36.303 回答
0

没有人发布答案,我做了什么找到插入表中的最后一个 id,就像这样

$last_inserted = $this->db->get_var("select product_id from oc_product order by product_id desc");

也许有一个直接的解决方案但是我搜索了文档并没有找到它,所以我使用了这行代码。

于 2019-11-15T13:36:25.877 回答