[eluser]Skinnpenal[/eluser]
Hi!
I'm having a hard time with my fulltext search after upgrading from 1.5.4 to 1.6.1.
My question is; how do
you do fulltext searches with codeigniter active record?
This is what I've tried:
Code:
$where = "MATCH (title) AGAINST ('$search_term')";
$ci->db->select('id, '.$where.' AS score');
$ci->db->where($where);
$ci->db->where("id IN ($pages_as_string)");
But with the escaping issue, this is the query produced:
Code:
SELECT `id`, `MATCH` (`title`) `AGAINST` ('my-search-term') AS score
FROM (`my-table`) WHERE `MATCH` (title) AGAINST ('my-search-term') AND `id` IN (1,2,3)
- Where you see that the
MATCH,
title,
AGAINST and
id in the end has been escaped, which natually causes the query to fail.
And so, I add the optional parameter to turn off escaping (
, false).
Code:
$ci->db->select('id, '.$where.' AS score', false);
$ci->db->where($where, false);
$ci->db->where("id IN ($pages_as_string)", false);
But then, for some strange reason, CI adds zero's to the SQL, and it ends up like this:
Code:
SELECT id, MATCH (title) AGAINST ('my-search-term') AS score
FROM (`my-table`) WHERE MATCH (title) AGAINST ('my-search-term') 0 AND id IN (1,2,3) 0
Anyone with tips on how I can fix this?