Is there any replacement for this query in PHP Yii2?
SELECT * FROM my_table WHERE my_column ?& array['2', '1', '3', '4'];
my_column = jsonb
Because i get this error
Error Info: Array
(
[0] => 42601
[1] => 7
[2] => ERROR: syntax error at or near "$1"
LINE 1: SELECT * FROM my_table WHERE my_column $1& array['2', '1', '3', '...
^
)
I'm using PHP Yii2 and PostgreSQL 9.4:
$sql = "SELECT * FROM my_table WHERE my_column ?& array['2', '1', '3', '4'];";
$model = TestModel::findBySql($sql)->asArray()->all();
The purpose of this query is compare if the value exists in the database.
The database have:
["1", "2", "3", "4"]
["1", "2", "3"]
And it works in the pgAdmin3 SQL Editor.
$1
,$2
, ...) so something in PHP is converting the?
in?&
to$1
as though the?
was a placeholder. That's where the odd$1
is coming from. Don't know enough about the PHP interface to tell you how to fix it though, sorry.$sq
l inyii\db\Expression
but seems like it didn't help.