-
-
# query comes from GET request parameter ‘q’
-
$input = $this->params[‘url’][‘q’];
-
-
# sanitize the query
-
uses(’sanitize’);
-
$sanitizer = new Sanitize();
-
$q = $sanitizer->clean($input);
-
-
# now the pagination options hack to perform a fulltext search
-
# we are searching a table called ‘listings’ with a fulltext index on
-
# `title` and `description`
-
$options[‘conditions’] =
array(
-
‘1′ => "1 AND MATCH(Listing.title,Listing.description)
-
AGAINST(’$q’ IN BOOLEAN MODE)"
-
);
-
-
$this->set(‘results’ => $this->paginate(‘Listing’, $options);
-
Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment