Yii Framework Forum: Best Method to Execute Complex Query - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Best Method to Execute Complex Query Rate Topic: -----

#21 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 09 April 2010 - 10:42 AM

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;
}

0

#22 User is offline   tommytwoeyes 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 08-March 10

Posted 09 April 2010 - 10:56 AM

View PostMike, on 09 April 2010 - 10:42 AM, said:

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!
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users