From 7a8bcd1ec523130e7b47c167fce5463d756d563e Mon Sep 17 00:00:00 2001 From: Neil Gladwin Date: Fri, 20 Oct 2017 13:38:06 +1000 Subject: [PATCH] Returns the last inserted ID using currval() which is session dependant rather than last_value which is across all sessions --- code/PostgreSQLConnector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/PostgreSQLConnector.php b/code/PostgreSQLConnector.php index 5619f93..0af69d0 100644 --- a/code/PostgreSQLConnector.php +++ b/code/PostgreSQLConnector.php @@ -116,8 +116,8 @@ class PostgreSQLConnector extends DBConnector public function getGeneratedID($table) { - $result = $this->query("SELECT last_value FROM \"{$table}_ID_seq\";")->first(); - return $result['last_value']; + $result = $this->query("SELECT currval('\"{$table}_ID_seq\"')")->first(); + return $result['currval']; } public function getLastError()