Commit 04ebd122 by Gevik Babakhani

Added last insert value to pgsql PDO

parent 97270a38
...@@ -25,6 +25,20 @@ class PDO extends \PDO { ...@@ -25,6 +25,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.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment