An easy-to-use Library to perform ranked fulltext searches with MYSQLi.
Install via composer:
{
"require": {
"alexschwarz89/EasyMysqliFulltext": "2.0.0"
}
}
Run composer install
.
You will find a example file in examples/index.php to use with the included testdata.sql.
use \Alexschwarz89\EasyMysqliFulltext\Search;
$search = new Search( $mysqliInstance );
$query = new SearchQuery($search);
$query->setTable('testdata')
->setSearchFields('description')
->mustInclude('example');
$search->setSearchQuery( $query );
try {
$search->execute();
} catch (EmptySearchTermException $e) {
// Handle invalid search terms
}
$search = Search::createWithMYSQLi('localhost', 'username', 'password', 'dbname');
$search = Search::createWithMYSQLi();
DATABASE_HOST=localhost
DATABASE_USERNAME=username
DATABASE_PASSWORD=password
DATABASE_NAME=database_name
$query->setTable('testdata')
->setSearchFields('description,title,isbn,author')
->mustInclude('example')
->canInclude('another')
->exclude('again')
->preferWithout('this')
->orderBy('some_field', 'ASC');
Contributing is surely allowed! :-)