Yii2 framework backup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Alexander Makarov ab799d8ea9 Fixes #2911: Removed `tbl_` default for table prefix 11 years ago
..
ActiveQuery.php Reformat code te be PSR-2 compatible 11 years ago
ActiveRecord.php reset dirty attributes after `afterSave` 11 years ago
CHANGELOG.md reset dirty attributes after `afterSave` 11 years ago
ColumnSchema.php Reformat code te be PSR-2 compatible 11 years ago
Command.php Fixes #2911: Removed `tbl_` default for table prefix 11 years ago
Connection.php Reformat code te be PSR-2 compatible 11 years ago
IndexSchema.php Reformat code te be PSR-2 compatible 11 years ago
LICENSE.md psr-4 change. 11 years ago
Query.php updated classmap and phpdoc 11 years ago
QueryBuilder.php Reformat code te be PSR-2 compatible 11 years ago
README.md psr-4 change. 11 years ago
Schema.php refactored code to use Instance::ensure() 11 years ago
composer.json replaced keyword "yii" with "yii2" in composer.json files (fixes #2557) 11 years ago

README.md

Sphinx Extension for Yii 2

This extension adds Sphinx full text search engine extension for the Yii 2 framework.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiisoft/yii2-sphinx "*"

or add

"yiisoft/yii2-sphinx": "*"

to the require section of your composer.json.

Usage & Documentation

This extension interacts with Sphinx search daemon using MySQL protocol and SphinxQL query language. In order to setup Sphinx "searchd" to support MySQL protocol following configuration should be added:

searchd
{
	listen = localhost:9306:mysql41
	...
}

This extension supports all Sphinx features including Runtime Indexes. Since this extension uses MySQL protocol to access Sphinx, it shares base approach and much code from the regular "yii\db" package.

To use this extension, simply add the following code in your application configuration:

return [
	//....
	'components' => [
		'sphinx' => [
			'class' => 'yii\sphinx\Connection',
			'dsn' => 'mysql:host=127.0.0.1;port=9306;',
			'username' => '',
			'password' => '',
		],
	],
];

This extension provides ActiveRecord solution similar ot the \yii\db\ActiveRecord. To declare an ActiveRecord class you need to extend \yii\sphinx\ActiveRecord and implement the indexName method:

use yii\sphinx\ActiveRecord;

class Article extends ActiveRecord
{
	/**
	 * @return string the name of the index associated with this ActiveRecord class.
	 */
	public static function indexName()
	{
		return 'idx_article';
	}
}

You can use \yii\data\ActiveDataProvider with the \yii\sphinx\Query and \yii\sphinx\ActiveQuery:

use yii\data\ActiveDataProvider;
use yii\sphinx\Query;

$query = new Query;
$query->from('yii2_test_article_index')->match('development');
$provider = new ActiveDataProvider([
	'query' => $query,
	'pagination' => [
		'pageSize' => 10,
	]
]);
$models = $provider->getModels();
use yii\data\ActiveDataProvider;
use app\models\Article;

$provider = new ActiveDataProvider([
	'query' => Article::find(),
	'pagination' => [
		'pageSize' => 10,
	]
]);
$models = $provider->getModels();