Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 881043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:11:52+00:00 2026-05-15T12:11:52+00:00

Hello I have a little problem with requests : In an action executeFiche, I

  • 0

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

EDIT

Thanks for this answer,

But when I want to put the queries in my model, I have others problems : I have an error, with ‘$request->getParameter(‘id’)’. I exchange it to ‘$this->getId()’ and Doctrine tell me I have an error.

For the parenthesis, I close them in the next. I don’t know another way to generate SQL with order in the where. It is to have :

WHERE l.id = $request->getParameter('id') AND ( b.datefin >= date('Y-m-d', time()) OR b.datefin = 0000-00-00 )

Edit : I still have my problem. When the second request have something to return, the first doesn’t return all the entries

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:11:52+00:00Added an answer on May 15, 2026 at 12:11 pm

    As a good symfony practice, you could start by putting the queries in a model (something like LogementTable.class.php).

    You have also some syntax problems in your queries.


    Update : I didn’t notice the parenthesis is closed on the line after

    In the following line, you open the parenthesis but it isn’t closed after :

    ->andWhere('(b.datefin >= ?', date('Y-m-d', time()))
    

    Second error, in SQL dates must be surrounded by quotes :

    ->orWhere("b.datefin = '0000-00-00')")
    // ...
    ->andWhere("b.datefin != '0000-00-00'")
    

    Update 2 :

    Try this as your second request :

     $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();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.