Yii Postgress Json 查询带问号的运算符 ?, ?|, ?&
Yii Postgress Json queries for operator with question marks ?, ?|, ?&
如何将 SQL 查询写入 support JSON where conditions matching operators ? , ?|, ?&.
id : 12,
name: 'Harry Pottor',
type: ['Fiction', 'Horror', 'Adventure' ]
在 Yii 中,当我为 JSON 数组编写查询时,使用 ?&
运算符检查会给我错误。此查询 运行 在 pgAdmin
中成功
SELECT id, name
FROM books
WHERE
type ?& array['Fiction', 'Horror']
$commandSql = $connection->createCommand($sql);
但是 ?
标记运算符被替换为 $1,即获取绑定值。
如何在 Yii 中进行此类查询?
我遇到同样的问题
SELECT * FROM company WHERE jsonb_exists_all(technology::jsonb, array['ERP']);
或
SELECT * FROM company WHERE jsonb_exists_all(technology, array['ERP']);
参考这个link
http://www.scriptscoop2.com/t/984beb7bce86/postgresql-json-select-query-replacement-in-php-yii2.html
如何将 SQL 查询写入 support JSON where conditions matching operators ? , ?|, ?&.
id : 12,
name: 'Harry Pottor',
type: ['Fiction', 'Horror', 'Adventure' ]
在 Yii 中,当我为 JSON 数组编写查询时,使用 ?&
运算符检查会给我错误。此查询 运行 在 pgAdmin
SELECT id, name
FROM books
WHERE
type ?& array['Fiction', 'Horror']
$commandSql = $connection->createCommand($sql);
但是 ?
标记运算符被替换为 $1,即获取绑定值。
如何在 Yii 中进行此类查询?
我遇到同样的问题
SELECT * FROM company WHERE jsonb_exists_all(technology::jsonb, array['ERP']);
或
SELECT * FROM company WHERE jsonb_exists_all(technology, array['ERP']);
参考这个link http://www.scriptscoop2.com/t/984beb7bce86/postgresql-json-select-query-replacement-in-php-yii2.html