Skip to content

Instantly share code, notes, and snippets.

@MrTrick
Created October 28, 2011 05:10
Show Gist options
  • Save MrTrick/1321670 to your computer and use it in GitHub Desktop.
Save MrTrick/1321670 to your computer and use it in GitHub Desktop.
<?
...
$select = new Zend_Db_Select($db=Zend_Db_Table::getDefaultAdapter());
$select->from(array('a'=>'tutors_applicant_application'));
//Filter on area?
if (isset($query['area']) and $query['area']!='all') {
$area = $query['area'];
$select->where('area=?',$area);
}
//Filter on interest?
if (isset($query['interest']) and $query['interest']!='all') {
$interests = is_array($query['interest']) ? $query['interest'] : array($query['interest']);
$select->join(array('i'=>'tutors_applicant_application_interest'), 'a.id=i.application_id', array());
foreach($interests as $interest)
$select->orWhere('interest = ?', $interest);
}
return new Tutors_Model_ApplicantApplication_Collection($db->fetchAll($select),$this);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment