Add support for yii\db\Expression to QueryBuiler simple conditions

fixes #5601
This commit is contained in:
Carsten Brandt
2014-10-17 13:32:54 +02:00
parent 179be14ce1
commit 292a9ff55b
5 changed files with 18 additions and 3 deletions

View File

@ -4,7 +4,7 @@ Yii Framework 2 sphinx extension Change Log
2.0.1 under development
-----------------------
- no changes in this release.
- Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow `yii\db\Expression` to be used as the value (cebe, stevekr)
2.0.0 October 12, 2014
@ -41,6 +41,7 @@ Yii Framework 2 sphinx extension Change Log
All relational queries are now directly served by `ActiveQuery` allowing to use
custom scopes in relations (cebe)
2.0.0-alpha, December 1, 2013
-----------------------------

View File

@ -1085,6 +1085,11 @@ class QueryBuilder extends Object
if ($value === null) {
return "$column $operator NULL";
} elseif ($value instanceof Expression) {
foreach ($value->params as $n => $v) {
$params[$n] = $v;
}
return "$column $operator {$value->expression}";
} else {
$phName = self::PARAM_PREFIX . count($params);
$params[$phName] = $value;