CodeIgniter Forums
Using MATCH AGAINST in datamapper with select_func() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Using MATCH AGAINST in datamapper with select_func() (/thread-54769.html)



Using MATCH AGAINST in datamapper with select_func() - El Forum - 09-24-2012

[eluser]Unknown[/eluser]
I am having a bad time trying to get a full text search to work in datamapper.
From much googling and studying the documentation etc I have come up with the following code:

Code:
$search = new Plant();          
            $search->select_func('MATCH("@genus","@species","@common_name") AGAINST ("'.$value.'")','relevance');
            $search->where('MATCH("@genus","@species","@common_name") AGAINST ("'.$value.'")');
            $search->having('relevance > 0.2');
            $search->order_by('relevance','desc');
            $s = $search->get();

this gives the error:

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"@genus","@species","@common_name") AGAINST ("daisy")() AS relevance FROM (`plan' at line 1

SELECT MATCH("@genus","@species","@common_name") AGAINST ("daisy")() AS relevance FROM (`plants`) WHERE MATCH("@genus","@species","@common_name") AGAINST ("daisy") HAVING `relevance` > 0.2 ORDER BY `relevance` desc

Filename: C:\[my dev server]\system\database\DB_driver.php

Line Number: 330

particularly puzzling is the '()' after ("daisy") - where does that come from?

can anyone shed any light on this?