I tried adding a calculated column into the “select” property of a CDbCriteria, it doesn’t work . I also tried using an array.
$q = new CDbCriteria(array(
'scopes' => 'notOwnedByUser',
'select' => '*, (MATCH (tbl_book_ftsearch.title, tbl_book_ftsearch.description) AGAINST ('*$match*')) AS SCORE',
'join' => 'LEFT JOIN tbl_book_ftsearch ON t.id = tbl_book_ftsearch.id',
'condition' => "LOWER(author) LIKE :match OR LOWER(publisher) LIKE :match OR MATCH (tbl_book_ftsearch.title, tbl_book_ftsearch.description) AGAINST ('*$match*' IN BOOLEAN MODE)",
'order' => 'score DESC',
'params' => array(':match' => "%$match%")
));
‘select’ => ', (MATCH (tbl_book_ftsearch.title, tbl_book_ftsearch.description) AGAINST (’$match*’)) AS score’,
instead of
‘select’ => ", (MATCH (tbl_book_ftsearch.title, tbl_book_ftsearch.description) AGAINST (’$match*’)) AS score",
now the select is built as it should be but I have to modify the query a little to make it works because now I get “Can’t find FULLTEXT index matching the column list.”