Tuesday, 6 August 2013

Order By UNION in Doctrine 2

Order By UNION in Doctrine 2

I want to display the 10 last elements viewed.
Here is my query in SQL :
SELECT compte.dateConsultation AS dateObjet, societe.nom FROM compte,
societe WHERE compte.idSociete = societe.id
UNION
SELECT opportunite.dateConsultation as dateObjet, opportunite.nom
FROM opportunite
UNION
SELECT contact.dateConsultation as dateObjet, CONCAT(CONCAT(personne.nom,
" "),personne.prenom)
FROM contact, personne
WHERE contact.idPersonne = personne.id
UNION
SELECT piste.dateConsultation as dateObjet, CONCAT(CONCAT(personne.nom, "
"),personne.prenom)
FROM piste, personne
WHERE piste.idPersonne = personne.id
UNION
SELECT tache.dateConsultation as dateObjet, tache.objet
FROM tache
UNION
SELECT evenement.dateConsultation as dateObjet, evenement.objet
FROM evenement
ORDER BY dateObjet DESC
I know that UNION is not supported in Doctrine. But I need to select all
elements and do an orderBy dateConsultation on the result.

No comments:

Post a Comment