PHP code example of mfjordvald / sphinxql
1. Go to this page and download the library: Download mfjordvald/sphinxql library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mfjordvald / sphinxql example snippets
'providers' => array(
'mfjordvald\Sphinxql\SphinxqlServiceProvider',
)
'aliases' => array(
'SphinxQL' => 'mfjordvald\Sphinxql\Facades\SphinxqlFacade',
)
php artisan config:publish mfjordvald/sphinxql
index rt_test
{
type = rt
path = /var/lib/sphinxsearch/data/rt
rt_field = title
rt_field = content
rt_attr_uint = gid
}
searchd
{
# Configure the searchd listening port.
listen = 9306:mysql41
binlog_path = /var/lib/sphinxsearch/data
pid_file = /var/www/sphinx-rt/app/storage/sphinx/searchd.pid
# sudo searchd -c sphinx.conf - to start search daemon listening on above port
# mysql -P 9306 -h 127.0.0.1 - connect to sphinx server daemon
}
Blog::created(function($model){
$qins = SphinxQL::query()->insert()->into('rt_test');
$qins->set(array('id'=>99, 'title'=>'My Title', 'content'=>'My Content', 'gid'=>444))->execute();
//more realistically, it will look something like
//$qins->set($model->toArray())->execute();
});
Blog::updated(function($model){
$qrepl = SphinxQL::query()->replace()->into('rt_test');
$qrepl->set(array('id'=>99, 'title'=>'My Title', 'content'=>'My Content', 'gid'=>444))->execute();
});
Blog::deleted(function($model){
SphinxQL::query()->delete()->from('rt_test')->where('id',$model->id)->execute();
});
$q = SphinxQL::query()->select()->from('rt_test')->match('content', 'test');
->execute();
dd($q->compile()->getCompiled());
SphinxQL::query()->meta();
$q = SphinxQL::raw('select * from rt_test');
$q = SphinxQL::query()->select()
->from('rt_test')
->match('content', 'test')
->execute();
dd(SphinxQL::with($q)->get('Blog'));
public function get($name=null, $key='id')