Hi,
dunno really how to name the topic so it’s informative enough.
I have A model that has relation HAS_MANY to B model.
A relations:
'b'=>array(self::HAS_MANY, 'B', 'a_id')
Now, B has several relations and some scopes that allow include that relations into model with options.
For example, B relations:
'c'=>array(self::HAS_MANY, 'C', 'b_id'),
'd'=>array(self::HAS_MANY, 'D', 'b_id'),
'e'=>array(self::HAS_MANY, 'E', 'b_id'),
Now i have scopes in B model:
public function c_or_d() {
// some logic here
$with = array('c'=>array('index'=>'id'));
return $this->with($with);
}
public function e_with_options() {
// even more logic
$with = array('e'=>array('joinType'=>'INNER JOIN', 'index'=>'id'));
return $this->with($with);
}
Now somewhere else i do:
A::model()->with(
array(
'b'=>array(
'scopes'=>array('c_or_d', 'e_with_options')
)
)
)->findByPk($id);
Now, what happens is that only the LAST scope applies its "with". So in above case only "e_with_options" will apply the "with" criteria. If i swap them, the "c_or_d" will apply the "with".
That happens first time to me, i’ve tried A LOT of different options, no way to declare 2 with with scopes.
Is it meant to be like this?
Thank you.