我正在编写一个PHP脚本,使用“ INSERT INTO y(x,x,x)VALUES(z,z,z)”之类的查询将数据插入表中。我有一个唯一的,主自动递增键,即在表格中,如何在插入数据并用新行更新密钥后立即获取该数字?
more information and example of use: http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
Depends on how you are making the queries, if you are using some DB abstraction layer or not...
mysql functions: mysql_insert_id
mysqli: mysqli->insert_id
PDO: PDO::lastInsertId
mysql_insert_id - 获取上次查询中生成的ID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.