繁体   English   中英

在执行任何查询pdo php之前,获取特定表的最后插入的系统ID。

[英]Get the last inserted system id of a certain table before doing any query pdo php

教程中,我找到了一种获取特定表的最后插入ID的方法(使用pdo)。

$result = $db->exec("INSERT INTO table(firstname, lastname) VAULES('John', 'Doe')");
$insertId = $db->lastInsertId();

他在获取ID之前先进行了查询,但我想做这样的事情,但我想获取他最后一次插入条目之前的ID,然后再进行任何查询。 How should i tell the code that it should check the last inserted id from this table 任何想法表示赞赏。

Update

我想获得last inserted id 特定表的不仅是数据库的最后插入的ID

尝试这个...

返回任何查询运行之前最后插入的ID。

select * from yourtable order by id desc limit 0,1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM