Using GROUP_CONCAT in a Model


Hello Guys!

I am trying to figure out a way to use GROUP_CONCAT in a model

 $this->hasMany('OrderItems', new OrderItem())
            ['items', 'aggregate' => 'group_concat', 'field' => 'name', 'type' => 'string']

But I have 2 problems:

  1. I cannot set a SEPARATOR and the second one is that if field is empty;
  2. I get a ‘0’ when there is no data, instead of an empty string like this:


i have created PR to address this.


This works great and solves both of the problems.

Thank you Romans!