Skip to content

Postgresql, how use ? in query? #15873

@m1roff

Description

@m1roff

What steps will reproduce the problem?

Create query with AR using jsonb operators ?, ?|, ?& (doc: https://www.postgresql.org/docs/9.4/static/functions-json.html)

Example:

$_arr = [9];
$q = Profile::find();
$q->andWhere(['?|', 'relationship', new Expression("array['$_arr']")]);
// $q->andWhere("$colName ?| array['$_arr']"); // even this type
$q->all();

What is the expected result?

Execution of SQL query like

SELECT * FROM "profile" WHERE "relationship" ?| array['9']

What do you get instead?

Execution of SQL query like

SELECT * FROM "profile" WHERE "relationship" $1| array['9']

2018-03-09_19-45-24

Additional info

Q A
Yii version 2.0.15-dev
PHP version 7.1
Operating system ubuntu16.04.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions