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
This commit is contained in:
2017-09-04 13:42:18 +00:00
parent 1b40529501
commit 82b25ae519

View File

@@ -2765,6 +2765,10 @@ class dblayeroo
} }
$this->debugLog ("Entering createRequest ()"); $this->debugLog ("Entering createRequest ()");
$sql = $this->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,")"); $this->debugLog ("Entering prepareRequest (XXX, ",false,")");
$st = $this->prepareRequest ($sql, false); $st = $this->prepareRequest ($sql, false);
$this->debugLog ("'",$this->getDisplayQuery (),"'"); $this->debugLog ("'",$this->getDisplayQuery (),"'");
@@ -2863,8 +2867,9 @@ class dblayeroo
else else
{ {
$this->debugLog ("INSERT: PgSQL INSERT without Autoincrement. ". $this->debugLog ("INSERT: PgSQL INSERT without Autoincrement. ".
"Return 1"); "Return the PK value defined in RETURN part");
return 1; $result = $st->fetch (PDO::FETCH_ASSOC);
return $result[$this->primary];
} }
} }
$this->debugLog ("INSERT: lastInsertId=", $this->debugLog ("INSERT: lastInsertId=",