mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-19 18:00:51 +08:00
Added last insert value to pgsql PDO
This commit is contained in:
@ -24,6 +24,20 @@ class PDO extends \PDO {
|
|||||||
|
|
||||||
private $_currentDatabase = null;
|
private $_currentDatabase = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns value of the last inserted ID.
|
||||||
|
* @param string|null $sequence the sequence name. Defaults to null.
|
||||||
|
* @return integer last inserted ID value.
|
||||||
|
*/
|
||||||
|
public function lastInsertId($sequence = null) {
|
||||||
|
if ($sequence !== null) {
|
||||||
|
$sequence = $this->quote($sequence);
|
||||||
|
return $this->query("SELECT currval({$sequence})")->fetchColumn();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here we override the default PDO constructor in order to
|
* Here we override the default PDO constructor in order to
|
||||||
* find and set the default schema search path.
|
* find and set the default schema search path.
|
||||||
|
Reference in New Issue
Block a user