请给我帮助。要完成此功能以显示所有j2表,但是如果$ nom_entrepot_client为null,则不执行j2.nom条件;如果不为null,则执行条件。
这是我的代码
public static function getlignes($pagenumber,$code,$nom_magasin,$nom_entrepot_client,$nom,$id_ville,$results){
$db = Zend_Db_Table::getDefaultAdapter();
$data = new Zend_Db_Select($db);
$select = $db->select()
->from(array('t' => 'clients'),
array('id_client',
'code',
'nom_magasin',
'CONCAT(t.nom," ",t.prenom) as client',
'fixe',
'mobile',
'fax'))
->join(array('j1' => 'villes'),
'j1.id_ville = t.id_ville',
array('nom as nom_ville'))
->joinleft(array('j2' => 'entrepots_client'),
't.id_client = j2.id_client',
array('nom as nom_entrepot_client'))
->where('t.code like ?',($code==null)? '%':$code)
->where('t.nom like ?',($nom==null)? '%':$nom)
->where('t.nom_magasin like ?',($nom_magasin==null)? '%':$nom_magasin)
**->where('j2.nom like ?',($nom_entrepot_client==null)? '%':$nom_entrepot_client)**
->where('t.id_ville like ?',((($id_ville==0)?null:$id_ville)==null)? '%':$id_ville)
->order(array('nom_ville','nom_magasin'));
$page = Zend_Paginator::factory($select);
$page->setCurrentPageNumber($pagenumber/$results+1);
$page->setItemCountPerPage($results);
return $page;
}