0

CakePHP Fulltext Search with Pagination

Posted October 28th, 2010 in CakePHP, Database, MySQL, PHP, Programming and tagged , , , , , , , , , by Louie Miranda

This is a working code that I was able to implement for my e-commerce application that uses cakephp full text search with pagination.

<?php
$this->paginate['Publication']['conditions'] = "MATCH(Publication.Code, Publication.Name, Publication.Language) AGAINST ('".$input."' IN BOOLEAN MODE)";
$this->paginate['Publication']['fields'] = "*, MATCH(Publication.Code, Publication.Name, Publication.Language) AGAINST ('".$input."' IN BOOLEAN MODE) AS score";
$this->paginate['Publication']['order'] = "score DESC";
$results = $this->paginate('Publication');
?>

Please make sure that you are using MyISAM on MySQL to fully implement this and you where able to set the full-text capability of the table.

Leave a Reply