CodeIgniter Forums

Full Version: Using MATCH AGAINST in datamapper with select_func()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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?