PDO::lastInsertId

PHP 教程 · 2019-01-28 17:28:03

PDO::lastInsertId — 返回最后插入行的ID或序列值(PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)

说明

语法

string PDO::lastInsertId ([ string $name = NULL ] )

返回最后插入行的ID,或者是一个序列对象最后的值,取决于底层的驱动。比如,PDO_PGSQL() 要求为 name 参数指定序列对象的名称。

注意: 在不同的 PDO 驱动之间,此方法可能不会返回一个有意义或一致的结果,因为底层数据库可能不支持自增字段或序列的概念。

参数

name
应该返回ID的那个序列对象的名称。

返回值

如果没有为参数 name 指定序列名称,PDO::lastInsertId() 则返回一个表示最后插入数据库那一行的行ID的字符串。

如果为参数 name 指定了序列名称,PDO::lastInsertId() 则返回一个表示从指定序列对象取回最后的值的字符串。

如果当前 PDO 驱动不支持此功能,则 PDO::lastInsertId() 触发一个 IM001 SQLSTATE 。

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Ethnography and Virtual Worlds

Ethnography and Virtual Worlds

Tom Boellstorff、Bonnie Nardi、Celia Pearce、T. L. Taylor / Princeton University Press / 2012-9-16 / GBP 21.00

"Ethnography and Virtual Worlds" is the only book of its kind - a concise, comprehensive, and practical guide for students, teachers, designers, and scholars interested in using ethnographic methods t......一起来看看 《Ethnography and Virtual Worlds》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具