Struggling a while with passing an array parameter for a simple Redshift (Postgres8) query like this:
// Example:
$sql = "select * from country where country_code IN ($1) LIMIT 10";
$params = ["'GB','US'"];
pg_send_query_params($conn, $sql, $params);
Redshift engine does not care about any "array" format I’m trying to pass
the same happens for integer[]
I’ve been trying passings parameters in a various ways like
"'GB','US'"
"{'GB','US'}"
"['GB','US']"
"('GB','US')"
"ARRAY['GB','US']"
// etc...
I’ve been also trying with cast operator for the parameter like
IN ($1::text[])
None of those work as expected
2
Answers
Thanks @FrankHeikens and @Stefanov.sm This works for Redshift
Thanks!
As @FrankHeikens commented, use
=any()
.or
Unrelated but it is highly recommended to use
PDO
instead ofpg_*
set of functions.