symfony2: how to use group_concat in QueryBuilder

If you want to use it in QueryBuilder you must :

1) add DQL functions GroupConcat: GroupConcat

2 ) Registering GroupConcat :DQL User Defined Functions

another alternative is to use NativeQuery :Native SQL


In symfony2 registering a function DQL it’s very simple just add GROUP_CONCAT in config.yml like:

    entity_managers:
        default:
            dql:
                string_functions:
                    GROUP_CONCAT: YourBundle\Query\Mysql\GroupConcat

For more information visit Registering Custom DQL Functions

Leave a Comment