You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It does not work if I pass params to new Expression()
AR::find()->where(newExpression(':item = ANY (array)', ['item' => 'value']))->all();
but it works if I pass params to where()
AR::find()->where(newExpression(':item = ANY (array)'), ['item' => 'value'])->all();
sometimes it is not comfortable when I pass where expression as parameter of function or method
functiongetAll($where) {
returnAR::find()->where($where)->all();
}
// it does not work$models = getAll(newExpression(':item = ANY (array)', ['item' => 'value']));
sometimes it is not comfortable when I pass where expression as parameter of function or method
function getAll($where) {
return AR::find()->where($where)->all();
}
And I agree with him. Sometimes it is handy to prepare where condition dynamically as a single object. In this case code where($expression) is more handy when where($expression->expression, $expression->params).
And if Expression using in some methods of QueryBuilder, it is good decision go use it in where(). Isn't it?
It does not work if I pass params to new Expression()
but it works if I pass params to where()
sometimes it is not comfortable when I pass where expression as parameter of function or method
This can be fixed if to add one more condition in
QueryBuilder::buildCondition()
https://github.com/yiisoft/yii2/blob/master/framework/db/QueryBuilder.php#L910
Also it requires for
QueryBuilder::buildAndCondition()
andQueryBuilder::buildNotCondition()
https://github.com/yiisoft/yii2/blob/master/framework/db/QueryBuilder.php#L975
https://github.com/yiisoft/yii2/blob/master/framework/db/QueryBuilder.php#L1004
to replace
if (is_array($operand)) {
onif (is_array($operand) || $operand instanceof Expression) {
The text was updated successfully, but these errors were encountered: