sphinx\ActiveQuery snippetByModel()

snippetByModel() public method

Sets the snippetCallback() to fetchSnippetSourceFromModels(), which allows to fetch the snippet source strings from the Active Record models, using method yii\sphinx\ActiveRecord::getSnippetSource().

For example:

class Article extends ActiveRecord
{
    public function getSnippetSource()
    {
        return file_get_contents('/path/to/source/files/' . $this->id . '.txt');;
    }
}

$articles = Article::find()->snippetByModel()->all();

Warning: this option should NOT be used with asArray() at the same time!

public $this snippetByModel ( )
return $this

The query object itself

doc_Yii
2016-10-30 17:11:32
Comments
Leave a Comment

Please login to continue.