bitmatix
(Bitmatix)
1
Can I use scopes in relations function like this???
public function relations()
{
return array(
'arrTeaserImage' => array(self::HAS_MANY, 'TeaserDocument', 'idTeaser',
'with' => 'objDisplayType:teaser'
)
);
}
In TeaserDocument I defined a scope named "teaser", but nothing happens…
qiang
(Qiang Xue)
2
teaser should be defined in the objDisplayType class…
bitmatix
(Bitmatix)
3
Quote
teaser should be defined in the objDisplayType class...
Sorry, my fault. Of course it is defined in objDisplayType class, but still nothing happens. It seems like the "with" is ignored…
qiang
(Qiang Xue)
4
What is the generated SQL? Note that 'with' option is only used by lazy loading.
bitmatix
(Bitmatix)
5
Quote
What is the generated SQL? Note that 'with' option is only used by lazy loading.
Ah ok, how can I handle it for the following?
Vehicle::model()->with('arrTeaserImage')->findAll();
Has it got to be like that:
Vehicle::model()->with('arrTeaserImage.objDisplayType:teaser')->findAll();
?
EDIT:
Yes, that works, but how can I define that in function "relations", for eager loading?
qiang
(Qiang Xue)
6
I just checked in a fix to make 'with' working with eager loading. Thanks.