1. Go to this page and download the library: Download ripaclub/sphinxsearch 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/ */
use SphinxSearch\Indexer;
$indexer = new Indexer($adapter);
$indexer->insert(
'foo',
[
'id' => 1,
'short' => 'Lorem ipsum dolor sit amet',
'text' => 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit ...'
],
true
);
const QUERY_MODE_PREPARED = 'prepared'; // use prepared statement
const QUERY_MODE_EXECUTE = 'execute'; // do not use prepared statement
const QUERY_MODE_AUTO = 'auto'; // auto detect best available option (prepared mode preferred)
use SphinxSearch\Query\QueryExpression;
$query = new QueryExpression('@title ? @body ?', ['hello', 'world']);
echo $query->toString(); //outputs: @title hello @body world
echo $query->setExpression('"?"/3')
->setParameters(['the world is a wonderful place, but sometimes people uses spe(ia| ch@rs'])
->toString(); //outputs: "the world is a wonderful place, but sometimes people uses spe\(ia\| ch\@rs"/3
echo $query->setExpression('? NEAR/? ? NEAR/? "?"')
->setParameters(['hello', 3, 'world', 4, '"my test"'])
->toString(); //outputs: hello NEAR/3 world NEAR/4 "my test"
use SphinxSearch\Adapter\Platform\SphinxQL;
use SphinxSearch\Db\Sql\Select;
use SphinxSearch\Db\Sql\Predicate\Match;
$select = new Select;
$select->from('myindex')
->where(new Match('? NEAR/? ? NEAR/? "?"', ['hello', 3, 'world', 4, '"my test"']))
->where(['enabled' => 1]);
//outputs: SELECT * from `foo` WHERE MATCH('hello NEAR/3 world NEAR/4 "my test"') AND `enabled` = 1
echo $select->getSqlString(new SphinxQL());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.