Bonjour,
Voilà la requête que j'aimerai faire avec Zend_db:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SELECT `P`.*, `C`.*, `Cl`.*, `Ag`.*, `V`.*, `Dpt`.*, `R`.*, `pa`.*, `F`.*, `E`.*, `Exp`.*, `S`.* 
FROM `postes` AS `P` 
LEFT JOIN `contrats` AS `C` ON P.poste_contrat = C.contrat_id 
LEFT JOIN `clients` AS `Cl` ON P.cli_id = Cl.cli_id 
LEFT JOIN `agences` AS `Ag` ON P.agence_id = Ag.agence_id 
LEFT JOIN `villes` AS `V` ON (P.ville_id = V.ville_id) 
LEFT JOIN `departements` AS `Dpt` ON (P.poste_dpt = Dpt.dpt_id) 
LEFT JOIN `regions` AS `R` ON (P.poste_region = R.region_id) 
LEFT JOIN `pays` AS `pa` ON (P.poste_pays = pa.pays_iso_number) 
LEFT JOIN `fonctions` AS `F` ON P.poste_fonction = F.fonction_id 
LEFT JOIN `etude` AS `E` ON P.poste_etude = E.etude_id 
LEFT JOIN `postes_exp` AS `Exp` ON P.poste_experience = Exp.postes_exp_id 
LEFT JOIN `secteurs` AS `S` ON P.poste_secteur = S.secteur_id 
WHERE ((poste_intitule LIKE '%secretaire medicale%' OR poste_intitule LIKE '%secretaire%' OR poste_intitule LIKE '%medicale%' ) 
OR (poste_description LIKE '%secretaire medicale%' OR poste_description LIKE '%secretaire%' OR poste_description LIKE '%medicale%' ) 
OR (agence_rs LIKE '%secretaire medicale%' OR agence_rs LIKE '%secretaire%' OR agence_rs LIKE '%medicale%' ) 
OR (cli_rs LIKE '%secretaire medicale%' OR cli_rs LIKE '%secretaire%' OR cli_rs LIKE '%medicale%')) 
ORDER BY case when poste_intitule LIKE '%secretaire medicale%' then 1 else 2 end,`poste_date_update` DESC
Tout fonctionne sauf l'order by case

Voici le code de l'order by case:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
 $tri='case when poste_intitule LIKE %'.$criteria['keys'].'% then 1 else 2 end';
 $select->order(array($tri, $order['sort'] . " " . $order['dir']));
Voici le message d'erreur que j'ai à l'exécution, l'order by case ne fonctionne pas:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'case when poste_intitule LIKE %secretaire medicale% then 1 else 2 end' in 'order clause'
Merci d'avance pour votre aide!