Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework > Zend_Db
Zend_Db Forum d'entraide pour le composant Zend_Db du Zend Framework (création de requêtes, abstraction, ORM etc.). Avant de poster -> FAQ Zend_Db.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 09/12/2010, 09h02   #1
Membre régulier
 
Inscription : janvier 2004
Messages : 440
Détails du profil
Informations forums :
Inscription : janvier 2004
Messages : 440
Points : 89
Points : 89
Par défaut Zend_db et order by case

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

Code :
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 :
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 :
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!
sheira est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/12/2010, 10h33   #2
Membre régulier
 
Inscription : janvier 2004
Messages : 440
Détails du profil
Informations forums :
Inscription : janvier 2004
Messages : 440
Points : 89
Points : 89
J'ai corrigé en mettant ça:
Code :
1
2
3
4
5
6
7
 
 $tri="(case when poste_intitule LIKE '%".$criteria['keys']."%' then 1 else 2 end)";
                for($i=0;$i<sizeof($keys);$i++) {
                    $tri .= ",(case when poste_intitule LIKE '%".$keys[$i]."%' then 1 else 2 end)";
		}
 
$select->order($tri . "," . $order['sort'] . " " . $order['dir']);
sheira est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 18h06.


 
 
 
 
Partenaires

Hébergement Web