Download the PHP package chris48s/cakephp-searchable without Composer
On this page you can find all versions of the php package chris48s/cakephp-searchable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chris48s/cakephp-searchable
More information about chris48s/cakephp-searchable
Files in chris48s/cakephp-searchable
Package cakephp-searchable
Short Description A CakePHP 3 Behavior for creating MySQL MATCH() AGAINST() queries
License MIT
Homepage https://github.com/chris48s/cakephp-searchable
Informations about the package cakephp-searchable
CakePHP Searchable Behavior Plugin
A CakePHP 3 Behavior for creating MySQL MATCH() AGAINST() queries.
CakePHP-Searchable adds a custom find('matches') method to your CakePHP models, alleviating the need to pass raw SQL into your queries. It is safe against SQL injection and uses a query syntax which is consistent with the conventions of CakePHP's ORM.
Installation
Install from packagist using composer.
Add the following to your composer.json:
and run composer install or composer update, as applicable.
Database Support
In order to use FULLTEXT indexes on InnoDB tables, you must be using MySQL >=5.6.4. Earlier versions only allow use of FULLTEXT indexes on MyISAM tables.
Usage
Loading the plugin
Add the code Plugin::load('Chris48s/Searchable'); to your bootstrap.php.
Using the Behavior
Add the behavior in your table class.
Querying data
Having added the behavior to a table class, you now have access to the query method find('matches'), which you can use to construct MATCH() AGAINST() queries. For example:
Available modes are:
'IN NATURAL LANGUAGE MODE''IN BOOLEAN MODE''WITH QUERY EXPANSION''IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION'
When using boolean mode, some additional operators are available.
The method find('matches') returns a CakePHP query object, so you can chain
additional methods on to this (e.g: ->where(), ->order(), ->limit(), etc).
Error Handling
If the keys 'match' or 'against' are not set, or if any of the columns contained in the column list are not of type string or text, an exception of class SearchableException will be thrown.
Reporting Issues
If you have any issues with this plugin then please feel free to create a new Issue on the GitHub repository. This plugin is licensed under the MIT Licence.