I would like to write this SQL query
select id FROM
(SELECT article.id AS id, MATCH(titre, intro, contenu) AGAINST ('query') as score FROM article ORDER BY score DESC) t1
where score>0
in doctrine with a querybuilder subquery.
I'am using a doctrine extension to interpret the MATCH AGAINST.
I cannot find the doctrine/querybuilder syntax to create the subquery inside the 'FROM'
So I do :
$this->createQueryBuilder('a')
->andWhere('MATCH(a.titre, a.intro, a.contenu) AGAINST (:q boolean) >0')
->orderBy('MATCH(a.titre, a.intro, a.contenu) AGAINST (:q boolean)', 'DESC')
->setParameter('q', $query)
This syntax is working but i would like to do it efficiently without repeating the 'MATCH(a.titre, a.intro, a.contenu) AGAINST (:q boolean)
twice.
So I need to write the subquery version.