PHP Manual
后退 |  | 前进

# PDO::lastInsertId

(no version information, might be only in CVS)

PDO::lastInsertId -- Returns the ID of the last inserted row

## Description

string PDO::lastInsertId ( [string name] )

警告
本函数是实验性的。本函数的行为，包括函数名称以及其它任何关于本函数的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本函数风险自担。

Returns the ID of the last inserted row, or the next value from a sequence object.

> 注: Due to differences between database server implementations, this method may not always return a meaningful result.

## 参数

name

  Name of the sequence object from which the ID should be returned.

## 返回值

If a sequence name was not specified for the name parameter, PDOStatement::lastInsertId() returns a string representing the row ID of the last row that was inserted into the database.

If a sequence name was specified for the name parameter, PDOStatement::lastInsertId() returns a string representing the next value retrieved from the specified sequence object.

If the PDO driver does not support this capability, PDO::lastInsertID() triggers an IM001 SQLSTATE.

后退 | 起点 | 前进
PDO::getAttribute | 上一级 | PDO::prepare