I have an action with two requests on an unique table. The results of the requests must be different.
But, the result is the same for my two requests and it comes from my second request.
// Récupération du (ou des) locataire(s) actuel(s) du logement
$this->locataires = Doctrine_Query::create()
->from('logement 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
$this->locatairesprec = Doctrine_Query::create()
->from('logement 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();
It maybe not the best way, but I have resolve the problem to select all the rows of my table in one request, and after, I sort the results using PHP