phpparametersdoctrinematchagainst

MATCH AGAINST in Doctrine


I found that if I use MATCH AGAINST in Doctrine with WHERE syntax does not replace the parameters passed. For example if I run the following code $

q = Doctrine_Query::create()
    ->select('*')
    ->from('TourismUnit tu')
    ->where('FALSE');
if ($keywords) {
    $keywords_array = $this->parse_keywords($keywords);
    for ($i = 0; $i < sizeof($keywords_array); $i++)
        $q->orWhere("MATCH (name, description) AGAINST ('?*' IN BOOLEAN MODE)", $keywords_array[$i]);
}

does not find any results. And if they use the string concatenation seems to work.

 $q->orWhere("MATCH (name, description) AGAINST ('".$keywords_array[$i]."*' IN BOOLEAN MODE)");

I use Doctrine 1.2.2.

Does anyone know why not replace the parameters before executing the sql expression?


Solution

  • the use of single quote causing the problem,
    convert it to use concat("'", ?, "*'")