is it possible to get data with a subselect in dql and putting the result in a class attribute which is not a entity column?
hasfreelist is a class attribute but not a entity column in mysql.
This is my dql:
SELECT e, DATE(e.begin) dbegin,
(SELECT COUNT(g) FROM AcmeDemoBundle:list g WHERE e.id = g.fkevent) AS e.hasfreelists
FROM AcmeDemoBundle:event e JOIN e.fklocation l
WHERE e.enabled=1 e.begin>=:from
ORDER BY dbegin, e.topevent DESC
I have the following error:
An exception has been thrown during the rendering of a template
("[Syntax Error] line 0, col 143: Error:
Expected Doctrine\ORM\Query\Lexer::T_FROM, got '.'")
But it tells me nothing.
Thank you for you help.
Seems to me you can define an association between
EventandList, and use theSIZEfunction to add your select. Much easier and logical that way:You can still define a
hasFreeListmethod on your entity class, which would returnsizeof($this->lists) > 0.But the reason you are getting this error, I think, is because you define your subselect as
e.hasfreelist. While it is a property of your class, this is a DQL syntax error (should be(SELECT x FROM y) AS z). Also, your Date select lacks theASoperator.