I am trying to update data in the column "name_local". This column is of type "hstore". The key would be for example 'fr' and the value 'Allemagne'.
If I execute the whole thing manually in the SQL console it works.
However, when I try to execute it as a prepared statement (PHP PDO), I always get syntax errors.
I think it is because of the quotation marks. I have also tried different ways. Single and double quotes, I escaped them. None of them worked.
Does anyone have any ideas?
This works fine in the console:
UPDATE country SET name_local = name_local || '''fr'' => ''Allemagne'''::hstore WHERE id = 1234;
This works also in PHP:
$stmt = $dbh2->prepare("UPDATE country SET name_local = name_local || '''fr'' => ''Afghanistan'''::hstore WHERE id = 996;");
$stmt->execute();
But if i do this:
$stmt = $dbh2->prepare("UPDATE country SET name_local = name_local || ''':iso2'' => '':name'''::hstore WHERE id = 996;");
$stmt->execute(['iso2'=>'en', 'name' => 'Afghanistan']);
i get this :
SQLSTATE[HY093]: Invalid parameter number: :iso2