From 27a352b998195c9a75c4716f8614441e94bad584 Mon Sep 17 00:00:00 2001 From: Leonardo Silvano Date: Thu, 7 Jul 2016 15:46:28 -0300 Subject: [PATCH] added support for Postgresql PDO::lastInsertId() --- src/Pixie/QueryBuilder/QueryBuilderHandler.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Pixie/QueryBuilder/QueryBuilderHandler.php b/src/Pixie/QueryBuilder/QueryBuilderHandler.php index 134fba0..9f9a6c6 100644 --- a/src/Pixie/QueryBuilder/QueryBuilderHandler.php +++ b/src/Pixie/QueryBuilder/QueryBuilderHandler.php @@ -310,7 +310,7 @@ public function subQuery(QueryBuilderHandler $queryBuilder, $alias = null) * * @return array|string */ - private function doInsert($data, $type) + private function doInsert($data, $type, $sequence = null) { $eventResult = $this->fireEvents('before-insert'); if (!is_null($eventResult)) { @@ -324,7 +324,7 @@ private function doInsert($data, $type) list($result, $executionTime) = $this->statement($queryObject->getSql(), $queryObject->getBindings()); - $return = $result->rowCount() === 1 ? $this->pdo->lastInsertId() : null; + $return = $result->rowCount() === 1 ? $this->pdo->lastInsertId($sequence) : null; } else { // Its a batch insert $return = array(); @@ -336,7 +336,7 @@ private function doInsert($data, $type) $executionTime += $time; if ($result->rowCount() === 1) { - $return[] = $this->pdo->lastInsertId(); + $return[] = $this->pdo->lastInsertId($sequence); } } } @@ -351,9 +351,9 @@ private function doInsert($data, $type) * * @return array|string */ - public function insert($data) + public function insert($data, $sequence = null) { - return $this->doInsert($data, 'insert'); + return $this->doInsert($data, 'insert', $sequence); } /** @@ -361,9 +361,9 @@ public function insert($data) * * @return array|string */ - public function insertIgnore($data) + public function insertIgnore($data, $sequence = null) { - return $this->doInsert($data, 'insertignore'); + return $this->doInsert($data, 'insertignore', $sequence); } /** @@ -371,9 +371,9 @@ public function insertIgnore($data) * * @return array|string */ - public function replace($data) + public function replace($data, $sequence = null) { - return $this->doInsert($data, 'replace'); + return $this->doInsert($data, 'replace', $sequence); } /**