Skip to content

Instantly share code, notes, and snippets.

@Tocacar
Created June 20, 2012 14:45
Show Gist options
  • Select an option

  • Save Tocacar/2960231 to your computer and use it in GitHub Desktop.

Select an option

Save Tocacar/2960231 to your computer and use it in GitHub Desktop.
Query idea
public function getCages($query, cageQueryParams $params)
{
$q = $this->createQuery('c')
->leftJoin('c.Strain s')
->leftJoin('c.MouseCage m')
->where('m.dateout IS NULL');
if($params->strainid) {
$q->addWhere('c.strain_id = ?', $params->strainid);
}
if($params->projectlicenceid) {
$q->addWhere('c.project_licence_id = ?', $params->projectlicenceid);
}
//lots more ifs here
$q->andWhere('c.is_active = ?', '1')
->addOrderBy('c.number DESC')
->limit(10);
return $q->execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment