In PHP PDO how to get "RETURNING" clause values of PostgreSQL upsert query
<p>I have this upsert query written in postgreSQL</p>

<pre><code>$statement = 'INSERT INTO "CharactersUnlockToBuyLevels"
                ("CharacterId", "LevelId", "AmountToBuy", "EagleStatueId", "Location", 
                 "MapCoordinateTop", "MapCoordinateLeft")
              VALUES 
                (:CharacterId, :LevelId, :AmountToBuy, :EagleStatueId, :Location, 
                 :MapCoordinateTop, :MapCoordinateLeft)
              ON CONFLICT
                ("CharacterId")
              DO UPDATE 
                SET 
                  "LevelId" = EXCLUDED."LevelId",
                  "AmountToBuy" = EXCLUDED."AmountToBuy",
                  "EagleStatueId" = EXCLUDED."EagleStatueId",
                  "Location" = EXCLUDED."Location",
                  "MapCoordinateTop" = EXCLUDED."MapCoordinateTop",
                  "MapCoordinateLeft" = EXCLUDED."MapCoordinateLeft"                            
              RETURNING "CharacterUnlockToBuyLevelId"
             ';
</code></pre>

<p>The query works fine, and if I run it in PgAdmin, I get the "CharacterUnlockToBuyLevelId" back as expected. However if I prepare it and execute it using PHP's PDO then I can't seem to get the RETURNING value back.</p>

<pre><code>$stmt = $this-&gt;db-&gt;prepare($statement);
$returnedId = $stmt-&gt;execute(array(
     'CharacterId' =&gt; $characterId,
     'LevelId' =&gt; $unlockMethod['LevelId'],
     'AmountToBuy' =&gt; $unlockMethod['AmountToBuy'],
     'EagleStatueId' =&gt; $unlockMethod['EagleStatueId'],
     'Location' =&gt; $unlockMethod['Location'],
     'MapCoordinateTop' =&gt; $unlockMethod['MapCoordinateTop'],
     'MapCoordinateLeft' =&gt; $unlockMethod['MapCoordinateLeft'],
));
</code></pre>

<p>This just returns true, so <code>$returnedId</code> will not actually hold the id but just the value true. How can I get the RETURNING value from the upsert query back with PDO's prepared statements?</p>