Best Method to Execute Complex Query

So why not add a parameterized scope to universities instead? Something like:


public function byTuition($something)

{

    $this->getDbCriteria()->mergeWith(array(

        'with'=>array(

            'tuition'=>array(

                'select'=>'(inStateTuition + booksSupplies + onCampusRoomBoard + onCampusOther) as totalTuition',

                'joinType'=>'INNER JOIN',

                'having'=>'totalTuition >= :min AND totalTuition <= :max',

                'params'=>...

            ),

        ),

    ));

    return $this;

}



D’oh! That’s so obvious. I am still learning to think in terms of Yii.

Thanks, Mike!