如何在 ezsql 最新版本 4 中获取 last_inserted_id?
how to get last_inserted_id in ezsql latest version 4?
尝试使用此行获取最后插入的 ID:
$db->insert_id;
但在最新版本的 ezsql 中 return 没有任何内容。
没有人回复,我找到最后一个id插入table,像这样
$last_inserted = $this->db->get_var("select product_id from oc_product order by product_id desc");
也许有一个直接的解决方案,但是我搜索了文档并没有找到,所以我使用了这行代码。
使用 select 获取最后一个 ID 可能有效,但并非总是如此。如果 2 个或更多用户同时插入,您可能无法获得正确的 ID。 $db->insert_id
已替换为 $db->getInsert_Id()
尝试使用此行获取最后插入的 ID: $db->insert_id;
但在最新版本的 ezsql 中 return 没有任何内容。
没有人回复,我找到最后一个id插入table,像这样
$last_inserted = $this->db->get_var("select product_id from oc_product order by product_id desc");
也许有一个直接的解决方案,但是我搜索了文档并没有找到,所以我使用了这行代码。
使用 select 获取最后一个 ID 可能有效,但并非总是如此。如果 2 个或更多用户同时插入,您可能无法获得正确的 ID。 $db->insert_id
已替换为 $db->getInsert_Id()