I have a two tables and corresponding models with a ‘has many’ relationship. It is easy to get all of table A’s B’s by using the expression:
$model = new A;
$a = $model::model()->findByPk(5);
$b = $a->b;
$b is then an array of related items. This is great, but how would I specify criteria so that I the above expression will only return B items with a column of some value? For example, what if I want only B items with a weight of 5 or above (weight being an integer column in the B table)?
Also, how would I do an order by?