I execute a simple postgresql update as:
UPDATE data SET Gender=lower(tmp.champs2)
FROM tmp WHERE data.email=tmp.champs1
AND (data.Gender IS NULL OR data.Gender='')
AND tmp.champs2 IS NOT NULL
AND tmp.champs2!=''
RETURNING Gender
The PostgreSQL documentation said we can get the number of rows affected with the RETURNING clause.
But how can I get this result with PHP, PDO?
I try something like:
echo $requete = "UPDATE data
SET ".$value."=lower(tmp.champs".$num.")
FROM tmp
WHERE data.email=tmp.champs".$email."
AND (data.".$value." IS NULL OR data.".$value."='')
AND tmp.champs".$num." IS NOT NULL
AND tmp.champs".$num."!=''
RETURNING ".$value;
$db->exec($requete);
$db->fetch(PDO::FETCH_NUM);
echo $row[0];
The correct number of rows updated are not returned.