簡體   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