I write this line at my controller
<i>
$model_town=ResTown::model()->with(array('get_by_town'))->findAll(array('limit'=>'3'));
</i>
I need to make get_by_town with limit=3 and user_active=1
I got all records but conditions don't work
I write this line at my controller
<i>
$model_town=ResTown::model()->with(array('get_by_town'))->findAll(array('limit'=>'3'));
</i>
I need to make get_by_town with limit=3 and user_active=1
I got all records but conditions don't work
收起
If you would like to add condition on related table you should write it inside with() method.
So, you should get something similar `
->with('get_by_town'=>array('limit'=>3, 'user_active'=>1))
But in some cases it can not helps you, because it depends on many things: for example, relation type, join type and so on.
The easiest way to work with ActiveRecord for me, first of all write down pure sql, and then convert to ActiveRecord representation. Thus, I get optimized query and exactly knowing of what I'm doing %)
报告相同问题?