mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
ported fix for #6164 to sphinx
was already supported for BETWEEN but not for LIKE fixes #6164
This commit is contained in:
@ -6,6 +6,7 @@ Yii Framework 2 sphinx extension Change Log
|
||||
|
||||
- Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow `yii\db\Expression` to be used as the value (cebe, stevekr)
|
||||
- Bug #5634: Fixed `yii\sphinx\QueryBuilder` does not support comparison operators (>,<,>= etc) in where specification (klimov-paul)
|
||||
- Bug #6164: Added missing support for `yii\db\Exression` to QueryBuilder `LIKE` conditions (cebe)
|
||||
- Enh #5223: Query builder now supports selecting sub-queries as columns (qiangxue)
|
||||
|
||||
|
||||
|
||||
@ -928,7 +928,9 @@ class QueryBuilder extends Object
|
||||
|
||||
list($column, $values) = $operands;
|
||||
|
||||
$values = (array) $values;
|
||||
if (!is_array($values)) {
|
||||
$values = [$values];
|
||||
}
|
||||
|
||||
if (empty($values)) {
|
||||
return $operator === 'LIKE' || $operator === 'OR LIKE' ? '0=1' : '';
|
||||
@ -947,8 +949,15 @@ class QueryBuilder extends Object
|
||||
|
||||
$parts = [];
|
||||
foreach ($values as $value) {
|
||||
$phName = self::PARAM_PREFIX . count($params);
|
||||
$params[$phName] = empty($escape) ? $value : ('%' . strtr($value, $escape) . '%');
|
||||
if ($value instanceof Expression) {
|
||||
foreach ($value->params as $n => $v) {
|
||||
$params[$n] = $v;
|
||||
}
|
||||
$phName = $value->expression;
|
||||
} else {
|
||||
$phName = self::PARAM_PREFIX . count($params);
|
||||
$params[$phName] = empty($escape) ? $value : ('%' . strtr($value, $escape) . '%');
|
||||
}
|
||||
$parts[] = "$column $operator $phName";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user