SQL function in SELECT

i’m still trying to get the GROUP_CONCAT function working. but <?php echo $daytrip->rTag->gTags; ?> remains empty.

hope you can help me out?

model Daytrip:

    public function relations()


        return array(

            'rCity' => array(self::BELONGS_TO, 'City', 'CityId'),

            'rTag' => array(self::MANY_MANY, 'Tag', 'DaytripTag(DaytripId, TagId)', 

                'select' => array('GROUP_CONCAT(Tag) AS gTags')),



view Daytrip:

<tr valign="top">

    <td><?php echo $daytrip->IdDaytrip; ?></td>

    <td><?php echo $daytrip->Daytrip; ?></td>

    <td><?php echo $daytrip->rCity->City; ?></td>

    <td>-<?php echo $daytrip->rTag->gTags; ?>-</td>

    <td><?php echo date('j M Y', strtotime($daytrip->Modified)); ?></td>


controller Daytrip:

$daytrips = Daytrip::model()->with('rCity', 'rTag')->findAll($criteria);

Since it is MANY_MANY relation, rTag should be an array.

sorry don’t get it. i thougt because of the GROUP_CONCAT i get a string “tag1, tag2, tag3” in the variable $daytrip->rTag->gTags.

where can i find that string?


BTW I noticed it’s possible to write something like “$daytrip->rTag->anything” with no error message.


Great, thank you!

in the view: <?php echo $daytrip->rTag2[0]->gTags; ?>

and in de model i added ‘group’ => ‘IdDaytrip’ to the realtion.