'sphinx' => [
'class' => 'system.db.CDbConnection',
'connectionString' => 'mysql:host=127.0.0.1;port=9306',
],
$sSql = 'SELECT id FROM posts WHERE MATCH('.Yii::$app->sphinx->quoteValue($term).')';
$ids = Yii::$app->sphinx->createCommand($sSql)->queryAll();
var_dump($ids); die();
Class system.db.CDbConnection does not exist
/**
* $inCategory
* @var boolean false - get posts from alien categories, true - from this category
*/
$postIds = $query
->select('id')
->from(Yii::$app->getModule('blog')->getParam('sphinxRtIndex'))
->match(new Expression(':match',
[
'match' => implode(' | ', $search)
]
))
->andWhere('id != :id', [':id' => $this->postModel->id])
->andWhere('category_id' . ($this->inCategory? '=' : '!=') . ':category_id',
[
':category_id' => $this->postModel->category_id
]
)
->limit($this->limit)
->all();
protected function replace() {
$params = [];
$sql = \Yii::$app->sphinx->getQueryBuilder()
->replace(
$this->rtIndex,
$this->getColumns(),
$params
);
return \Yii::$app->sphinx->createCommand($sql, $params)->execute();
}
/**
* $this->getColumns() возвращает массив вида:
* ['title' => 'John Doe', 'text' => 'I knew John well...']
*
* $this->rtIndex - содержит значение имени Realtime индекса
*/