Commit 0275a224 by Klimov Paul

Option array value support added to "yii\sphinx\Query"

parent aae221dd
...@@ -871,8 +871,28 @@ class QueryBuilder extends Object ...@@ -871,8 +871,28 @@ class QueryBuilder extends Object
if ($value instanceof Expression) { if ($value instanceof Expression) {
$actualValue = $value->expression; $actualValue = $value->expression;
} else { } else {
$actualValue = self::PARAM_PREFIX . count($params); if (is_array($value)) {
$params[$actualValue] = $value; $actualValueParts = [];
foreach ($value as $key => $valuePart) {
if (is_numeric($key)) {
$actualValuePart = '';
} else {
$actualValuePart = $key . ' = ';
}
if ($valuePart instanceof Expression) {
$actualValuePart .= $valuePart->expression;
} else {
$phName = self::PARAM_PREFIX . count($params);
$params[$phName] = $valuePart;
$actualValuePart .= $phName;
}
$actualValueParts[] = $actualValuePart;
}
$actualValue = '(' . implode(', ', $actualValueParts) . ')';
} else {
$actualValue = self::PARAM_PREFIX . count($params);
$params[$actualValue] = $value;
}
} }
$optionLines[] = $name . ' = ' . $actualValue; $optionLines[] = $name . ' = ' . $actualValue;
} }
......
...@@ -131,6 +131,10 @@ class QueryTest extends SphinxTestCase ...@@ -131,6 +131,10 @@ class QueryTest extends SphinxTestCase
->where("MATCH('about')") ->where("MATCH('about')")
->options([ ->options([
'cutoff' => 50, 'cutoff' => 50,
'field_weights' => [
'title' => 10,
'content' => 3,
],
]) ])
->all($connection); ->all($connection);
$this->assertNotEmpty($rows); $this->assertNotEmpty($rows);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment