Skip to content
Advertisement

Tag: symfony

How to group by only year in DQL?

How can I translate this query to Doctrine Query Language Answer Since your query only needs to group by year from a datetime column, you will need the YEAR function, which is not supported by default in DQL. You can install DoctrineExtensions which will add the functionality you need. And then edit the doctrine config file (config/packages/doctrine.yaml) as follow: Now

Symfony doctrine orderby and group by (distinct)

I am trying to get the latest booked courses (unique). I have tried the following with the Doctrine querybuilder: Without the orderby it works but it will traverse the bookings ascending. I need the latest booked courses. With this query I am getting this error: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not

Advertisement