Hello,
Hello I have a little problem with requests : In an action executeFiche, I have three requests
public function executeFiche(sfWebRequest $request){
// Récupération du logement correspondant à l'ID passé dans l'URL
$this->forward404Unless($this->logement = Doctrine::getTable('Logement')->find(array($request->getParameter('id'))), sprintf('Object logement does not exist (%s).', $request->getParameter('id')));
// Récupération du (ou des) locataire(s) actuel(s) du logement
$locataires = Doctrine::getTable('Logement')->createQuery('l')
->leftJoin('l.Bail b')
->leftJoin('b.Locataire')
->where('l.id = ?', $request->getParameter('id'))
->andWhere('(b.datefin >= ?', date('Y-m-d', time()))
->orWhere('b.datefin = 0000-00-00)')
->execute();
// Récupération du (ou des) locataire(s) précédent(s) du logement
$locatairesprec = Doctrine::getTable('Logement')->createQuery('l')
->leftJoin('l.Bail b')
->leftJoin('b.Locataire')
->where('l.id = ?', $request->getParameter('id'))
->andWhere('b.datefin < ?', date('Y-m-d', time()))
->andWhere('b.datefin != 0000-00-00')
->orderBy('datedeb')
->execute();
$this->locataires = $locataires;
$this->locatairesprec = $locatairesprec;
}
The problem is my two requests (the first is alright) hinder themselves and the result returned is wrong.
Edit : SQL request
SELECT l.id AS l__id, l.adresse AS l__adresse, l.montee AS l__montee, l.etage AS
l__etage, l.numetage AS l__numetage, l.numlogt AS l__numlogt, l.taille AS l__taille,
l.surfacehab AS l__surfacehab, l.typelog AS l__typelog, l.intergen AS l__intergen,
l.ascenseur AS l__ascenseur, l.ascenseuracc AS l__ascenseuracc, l.accessibl AS
l__accessibl, l.adaptable AS l__adaptable, l.adapte AS l__adapte, l.chauffage AS
l__chauffage, l.chargeschauf AS l__chargeschauf, l.chargeseauch AS l__chargeseauch,
l.chargeseaufr AS l__chargeseaufr, l.reservataire AS l__reservataire, l.loyer AS
l__loyer, l.loyercc AS l__loyercc, l.commentaires AS l__commentaires, l.created_at AS
l__created_at, l.updated_at AS l__updated_at, b.id AS b__id, b.locataire AS b__locataire,
b.logement AS b__logement, b.datedeb AS b__datedeb, b.datefin AS b__datefin, b.colloc AS
b__colloc, b.bailglissant AS b__bailglissant, l2.nud AS l2__nud, l2.titre AS l2__titre,
l2.nom AS l2__nom, l2.prenom AS l2__prenom, l2.nationalite AS l2__nationalite,
l2.datenaissance AS l2__datenaissance, l2.statutmatri AS l2__statutmatri, l2.statutpro AS
l2__statutpro, l2.nbenfants AS l2__nbenfants, l2.monoparental AS l2__monoparental,
l2.numprec AS l2__numprec, l2.rueprec AS l2__rueprec, l2.quartierprec AS l2__quartierprec,
l2.codepostalprec AS l2__codepostalprec, l2.villeprec AS l2__villeprec, l2.statutlogprec
AS l2__statutlogprec FROM logement l LEFT JOIN bail b ON l.id = b.logement LEFT JOIN
locataire l2 ON b.locataire = l2.nud WHERE (l.id = '1' AND (b.datefin >= '2010-07-01' OR
b.datefin = '0000-00-00'))
0.03s, "doctrine" connection
#
SELECT l.id AS l__id, l.adresse AS l__adresse, l.montee AS l__montee, l.etage AS
l__etage, l.numetage AS l__numetage, l.numlogt AS l__numlogt, l.taille AS l__taille,
l.surfacehab AS l__surfacehab, l.typelog AS l__typelog, l.intergen AS l__intergen,
l.ascenseur AS l__ascenseur, l.ascenseuracc AS l__ascenseuracc, l.accessibl AS
l__accessibl, l.adaptable AS l__adaptable, l.adapte AS l__adapte, l.chauffage AS
l__chauffage, l.chargeschauf AS l__chargeschauf, l.chargeseauch AS l__chargeseauch,
l.chargeseaufr AS l__chargeseaufr, l.reservataire AS l__reservataire, l.loyer AS l__loyer,
l.loyercc AS l__loyercc, l.commentaires AS l__commentaires, l.created_at AS l__created_at, l.updated_at AS l__updated_at, b.id AS b__id, b.locataire AS b__locataire,
b.logement AS b__logement, b.datedeb AS b__datedeb, b.datefin AS b__datefin, b.colloc AS
b__colloc, b.bailglissant AS b__bailglissant, l2.nud AS l2__nud, l2.titre AS l2__titre,
l2.nom AS l2__nom, l2.prenom AS l2__prenom, l2.nationalite AS l2__nationalite,
l2.datenaissance AS l2__datenaissance, l2.statutmatri AS l2__statutmatri, l2.statutpro AS
l2__statutpro, l2.nbenfants AS l2__nbenfants, l2.monoparental AS l2__monoparental,
l2.numprec AS l2__numprec, l2.rueprec AS l2__rueprec, l2.quartierprec AS l2__quartierprec,
l2.codepostalprec AS l2__codepostalprec, l2.villeprec AS l2__villeprec, l2.statutlogprec
AS l2__statutlogprec FROM logement l LEFT JOIN bail b ON l.id = b.logement LEFT JOIN
locataire l2 ON b.locataire = l2.nud WHERE (l.id = '1' AND b.datefin < '2010-07-01' AND
b.datefin != '0000-00-00') ORDER BY datedeb