Pdo Lastinsertid
# PDO::lastInsertId
[PHP PDO Reference](#)
PDO::lastInsertId β Returns the ID of the last inserted row or the value of a sequence (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
* * *
## Description
### Syntax
string PDO::lastInsertId ([ string $name = NULL ] )
Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver. For example, PDO_PGSQL() requires the name parameter to be specified for the sequence object.
**Note:** This method may not return a meaningful or consistent result across different PDO drivers, because the underlying database may not support the concept of auto-incrementing fields or sequences.
* * *
## Parameters
**name**
The name of the sequence object from which the ID should be returned.
* * *
## Return Value
If the sequence name parameter is not specified, PDO::lastInsertId() returns a string representing the row ID of the last row inserted into the database.
If the sequence name parameter is specified, PDO::lastInsertId() returns a string representing the last value retrieved from the specified sequence object.
If the current PDO driver does not support this capability, PDO::lastInsertId() triggers an IM001 SQLSTATE.
[PHP PDO Reference](#)
YouTip