mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-18 17:21:26 +08:00
Method "callSnippetsInternal" for the Sphinx Query extracted
This commit is contained in:
@ -201,4 +201,19 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
protected function callSnippets(array $source)
|
||||||
|
{
|
||||||
|
$from = $this->from;
|
||||||
|
if ($from === null) {
|
||||||
|
/** @var ActiveRecord $modelClass */
|
||||||
|
$modelClass = $this->modelClass;
|
||||||
|
$tableName = $modelClass::indexName();
|
||||||
|
$from = [$tableName];
|
||||||
|
}
|
||||||
|
return $this->callSnippetsInternal($source, $from[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -692,6 +692,18 @@ class Query extends Component implements QueryInterface
|
|||||||
* @return array snippets list.
|
* @return array snippets list.
|
||||||
*/
|
*/
|
||||||
protected function callSnippets(array $source)
|
protected function callSnippets(array $source)
|
||||||
|
{
|
||||||
|
return $this->callSnippetsInternal($source, $this->from[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a snippets from provided source data by the given index.
|
||||||
|
* @param array $source the source data to extract a snippet from.
|
||||||
|
* @param string $from name of the source index.
|
||||||
|
* @return array snippets list.
|
||||||
|
* @throws InvalidCallException in case [[match]] is not specified.
|
||||||
|
*/
|
||||||
|
protected function callSnippetsInternal(array $source, $from)
|
||||||
{
|
{
|
||||||
$connection = $this->getConnection();
|
$connection = $this->getConnection();
|
||||||
$match = $this->match;
|
$match = $this->match;
|
||||||
@ -699,7 +711,7 @@ class Query extends Component implements QueryInterface
|
|||||||
throw new InvalidCallException('Unable to call snippets: "' . $this->className() . '::match" should be specified.');
|
throw new InvalidCallException('Unable to call snippets: "' . $this->className() . '::match" should be specified.');
|
||||||
}
|
}
|
||||||
return $connection->createCommand()
|
return $connection->createCommand()
|
||||||
->callSnippets($this->from[0], $source, $match, $this->snippetOptions)
|
->callSnippets($from, $source, $match, $this->snippetOptions)
|
||||||
->queryColumn();
|
->queryColumn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user