From 82b25ae51939005476c832358a543aba66940dcf Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 4 Sep 2017 13:42:18 +0000 Subject: [PATCH] dblayeroo: PgSQL return the PK valeu added in INSERT if there is no AUTOINCREMENT primary field git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3918 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayeroo.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dblayeroo.php b/dblayeroo.php index 995b2ca..9447287 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -2765,6 +2765,10 @@ class dblayeroo } $this->debugLog ("Entering createRequest ()"); $sql = $this->createRequest (); + if ($this->driver === "pgsql" && $this->command === "INSERT") + { + $sql .= " RETURNING ".$this->sep.$this->primary.$this->sep; + } $this->debugLog ("Entering prepareRequest (XXX, ",false,")"); $st = $this->prepareRequest ($sql, false); $this->debugLog ("'",$this->getDisplayQuery (),"'"); @@ -2863,8 +2867,9 @@ class dblayeroo else { $this->debugLog ("INSERT: PgSQL INSERT without Autoincrement. ". - "Return 1"); - return 1; + "Return the PK value defined in RETURN part"); + $result = $st->fetch (PDO::FETCH_ASSOC); + return $result[$this->primary]; } } $this->debugLog ("INSERT: lastInsertId=",