[英]How to get the number of last added record with PDO SQLite in PHP?
I have the sqlite-table with ID field that is PRIMARY_KEY. 我有一个带有ID字段的sqlite表,它是PRIMARY_KEY。 I add the new record to database by the next code: 我通过下一个代码将新记录添加到数据库:
$textQuery = "INSERT INTO ".$table_name." VALUES ($numberRec,"."'".$a."'".",".$listNumbers.")";
$db->exec($textQuery);
Is there any simple way to define the number of last record to table in order to set $numberRec to needed value? 是否有任何简单的方法来定义表的最后一个记录的数量,以便将$ numberRec设置为所需的值? Or I have to make SELECT and so on? 或者我必须制作SELECT等等?
我相信你可以做$db->lastInsertId()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.