I need to do this query:
SELECT * FROM property_select(ARRAY[8,9,10,11,12,13,14,15,16,17,19,20,26,28])
using PHP function pg_query_params($prepared, $params).
Prepared query is:
SELECT * FROM property_select($1);
Params are: ["ARRAY[8,9,10,11,12,13,14,15,16,17,19,20,26,28]"]
How can I pass the params to pg_query_params() as array?
It’s not possible to use '{8,9,10,11,12,13,14,15,16,17,19,20,26,28}' postgres arrays (because it may contain strings and strings inside this array may contain , and “).
Find the detailed requirements for PostgreSQL Array Input and Output Syntax in the manual.
Basically, you need to enclose array elements with special characters in double quotes
"". You can double-quote all elements, but you don’t have to. And, I quote the manual (see above):There is a piece of PHP code posted by a user in the manual:
There is also a related answer here on SO:
Also consider the setting of
standard_conforming_strings. Backslashes may need to be doubled, but PHP’s pg-modules should do that for you automatically.