Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
Je cherche à faire une recherche du type suivant :
public function search($word, $argument1, $argument2) { $query = $this->select()->setIntegrityCheck(false) ->from(array('u' => 'user')) ->join(array('cc' => 'cc'), 'u.user_cc_fk = cc.cc_id') ->join(array( etc ….. ->where("nom LIKE '%$word%'") ->where('untruc = ?', $word) if ($argument1 == true) ->where('unAutreTruc IS null') if ($argument2 == 5) ->order('toto') ->limit(10); return $this->fetchAll($query); }
Bien sûr elle ne fonctionne pas, mais j’aimerais ne pas copier X fois cette fonction de recherche pour changer juste un ‘where()’. Surtout qu’en vrai elle fait 25 lignes…
Avez-vous une idée comment tout mettre dans une seul fonction.
Hors ligne
essaye ça :
public function search($word, $argument1, $argument2) { $query = $this->select()->setIntegrityCheck(false) ->from(array('u' => 'user')) ->join(array('cc' => 'cc'), 'u.user_cc_fk = cc.cc_id') ->join(array( etc ….. ->where("nom LIKE '%$word%'") ->where('untruc = ?', $word) ->limit(10); if ($argument1) { $query->where('unAutreTruc IS null'); } if ($argument2 == 5) { $query->order('toto'); } return $this->fetchAll($query); }
Hors ligne
merci ça marche!
c'étais tellement évident ....
Hors ligne