1. Go to this page and download the library: Download rpsl/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/ */
rpsl / sphinxql example snippets
$sphinxql = new SphinxQL();
$query = $sphinxql->newQuery();
$query
->addIndex('my_index')
->addField('field_name', 'alias')
->addField('another_field')
->addFields(
array(
array('field' => 'title', 'alias' => 'title_alias'),
array('field' => 'user_id')
)
)
->search('some words to search for')
// string (is given directly to sphinx, so can contain @field directives)
->where('time', time()-3600, '>', FALSE)
// field, value, operator='=', quote=TRUE
->whereIn('tags_i_need', array(1, 2, 3), 'all')
->whereIn('tags_i_do_not_want', array(4, 5, 6), 'none')
// field, array values, type='any'
->whereIn('tags_i_would_like_one_of', array(7, 8, 9), 'any')
// field, sort='desc'
->order('@weight', 'desc')
// defaults are 0 and 20, same as the sphinx defaults
->offset(10)->limit(50)
// option name, option value
->option('max_query_time', '100')
->groupBy('field')
// sphinx-specific, check their docs
->in_group_order_by('another_field', 'desc');
$result = $query->execute();
// get stats
$stats = $sphinx->stats();