I'm trying to sort a query by relevance with cakephp using paginator, but it simply ignores the alias, I already researched the manual but so far I have not found the solution, the query works perfectly, when I give a debug it generates the query below, but the order by does not appear see:
SELECT *, MATCH ('titulo','conteudo') AGAINST ('e-mail marketing' IN BOOLEAN MODE) AS relevance, MATCH ('titulo') AGAINST ('e-mail marketing' IN BOOLEAN MODE) AS title_relevance FROM 'db_forum'.'ra_forum' AS 'Forum' WHERE MATCH (titulo,conteudo) AGAINST ('e-mail marketing' IN BOOLEAN MODE) LIMIT 10
Follow the code:
$this->paginate = array(
'fields' => array('*', "MATCH ('titulo','conteudo') AGAINST ('$q' IN BOOLEAN MODE) AS relevance, MATCH ('titulo') AGAINST ('$q' IN BOOLEAN MODE) AS title_relevance"),
'conditions' => "MATCH ('titulo','conteudo') AGAINST ('$q' IN BOOLEAN MODE)",
'order' => array( 'relevance' => 'desc', 'title_relevance' => 'desc'),
'limit' => 10
);
Is it any good for this to work?
Edit: