IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Problème dans un formulaire


Sujet :

Symfony PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Mars 2011
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 65
    Par défaut Problème dans un formulaire
    Bonjour,
    Je suis entrain de développer un formulaire de recherche de la liste des utilisateurs suivant certains critères entrés par l'utilisateur.
    En effet, dans mon template FiltreSuccess.php j'ai ecrit comme suit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
     
    <h1>Requêtes</h1>
    <div align="right"><a href="<?php echo url_for('prostate_recap/excel') ?>"  ><img src="/images/excel.jpg" alt="Exporter le résultat en excel"></a></div>
    <form method="POST" action ="<?php echo url_for('prostate_recap/filtre') ?>">
        <table>
    <tr style="height:20px;">
                                <th>Extempo :</th>
                                <td>
                                    <input type="checkbox" name="extmY" <?php if (@$exY == '1') { ?> checked="checked" <?php } ?> value="1"/> oui
                                    <input type="checkbox" name="extmN"  <?php if (@$exN == '2') { ?> checked="checked" <?php } ?> value="2"/> non
                                </td>
                            </tr>
     
                             <tr style="height:20px;">
                                <th>Recoupe :</th>
                                <td>
                                    <input type="checkbox" name="recoupeY" <?php if (@$recY == '2') { ?> checked="checked" <?php } ?> value="2"/> Négatif
                                    <input type="checkbox" name="recoupeN"  <?php if (@$recN == '1') { ?> checked="checked" <?php } ?> value="1"/> Positif
                                </td>
                            </tr>
     <tr><td></td><td><input class="bouton tfoot" type="submit" value="Rechercher"></td></tr>
                        </tbody>
                    </table>
                </td>
                <td style="vertical-align:top;text-align:left;">
                    <table>
                        <?php if (count(@$patients)): ?>
                        <?php foreach (@$patients as $d): ?>
                                            <tr>
                                                <td><?php echo @$d->getName() . "&nbsp;" . @$d->getFirstname(); ?></td>
                                            </tr>
                        <?php endforeach; ?>
                        <?php endif; ?>
                                        </table>
                                    </td>
                                </tr>
                            </table>
    et dans mon actions.class.php j'ai utilisé le script suivant pour l'action executeFiltre:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
     
    $extmY = $request->getParameter('extmY');
    $extmN = $request->getParameter('extmN');
    $recoupeY = $request->getParameter('recoupeY');
    $recoupeN = $request->getParameter('recoupeN');
     $pA = Doctrine::getTable('Anapath')->createQuery('a');
            $qA = $pA->where('1 = 1');
    ///////////////////////////// Extempo
            if (($extmY != "") && ($extmN == "")) {
     
                $qA = $qA->addwhere('a.extemp =?', $extmY);
                $qA = $qA->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
    //            if ($this->cnt != 0) {
                $this->tabj = array_merge($this->tabj, $tablepatientida);
                $this->exY = $extmY;
            } else if (($extmN != "") && ($extmY == "")) {
                $qA = $qA->addwhere('a.extemp =?', $extmN);
                $qA = $qA->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
                $this->tabj = array_merge($this->tabj, $tablepatientida);
     
     
                $this->exN = $extmN;
            }
            if (($extmN != "") && ($extmY != "")) {
                $this->exY = $extmY;
                $this->exN = $extmN;
            }
             ///////////////////////////// Recoupe
            if (($recoupeY != "") && ($recoupeN == "")) {
     
                $qA = $qA->addwhere('a.recoupe_extemp =?', $recoupeY);
                $qA = $qA->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
                $this->tabj = array_merge($this->tabj, $tablepatientida);
                $this->recY = $recoupeY;
            }
            else if (($recoupeN != "") && ($recoupeY == "")) {
                $qA = $qA->addwhere('a.recoupe_extemp =?', $recoupeN);
                $qA = $qA->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
                $this->tabj = array_merge($this->tabj, $tablepatientida);
     
     
                $this->recN = $recoupeN;
            }
            else if (($recoupeN != "") && ($recoupeY != "")) {
                $this->recY = $recoupeY;
                $this->recN = $recoupeN;
            }
      $this->patients = $q->execute();
            $this->getUser()->setAttribute("patientstable", $this->patients);
    Mon probléme actuel est que lorsque je sélectionne une option de recoupe et une autre de extempo alors l'erreur suivante s'affiche:
    Fatal error: Call to undefined method Doctrine_Collection::addwhere() in D:\imm1\apps\front\modules\prostate_recap\actions\actions.class.php on line 1239
    Alors que si je choisi une seule option alors le fonctionnement est normal et j'obtient un résultat.
    Pouvez vous m'aider pour savoir ou se situe le problème exactement pour que je puisse faire une recherche suivant plusieurs options?
    Merci par avance.

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 18
    Par défaut
    Bonjour,

    Lorsque tu fais "$qA = $qA->execute()" $qA devient un objet Doctrine_Collection est n'a donc pas de méthode addWhere contrairement à l'objet Doctrine_Query.

    Il faut donc terminer ta requête (avec les "where") avant de l'exécuter ($qA->execute()).

  3. #3
    Membre confirmé
    Inscrit en
    Mars 2011
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 65
    Par défaut
    Je vous remercie pour votre réponse trés précise qui m'a résolu une partie de mon probléme.
    Ce que j'ai constaté est que lorsque je fait une recherche des patients qui vérifient les conditions extempo et recoupe alors l'affichage des patients affiche les patients qui vérifient la condition extempo Ou la condition recoupe:condition d'union.
    Mon but est d'afficher les patient qui vérifient exactement les deux conditions.
    Mon script de l'action est devenue:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
     
    $p = Doctrine::getTable('Patient')->createQuery('a');
            $q = $p->where('1 = 1');
      ///////////////////////////// Extempo
            if (($extmY != "") && ($extmN == "")) {
     
            $qA = Doctrine::getTable('Anapath')->createQuery('a')
                   ->where('1 = 1')
                   ->addwhere('a.extemp =?', '1')
                   ->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
    //            if ($this->cnt != 0) {
                $this->tabj = array_merge($this->tabj, $tablepatientida);
                $this->exY = $extmY;
            } else if (($extmN != "") && ($extmY == "")) {
                $qA = Doctrine::getTable('Anapath')->createQuery('a')
                   ->where('1 = 1')
                   ->addwhere('a.extemp =?', '0')
                   ->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
                $this->tabj = array_merge($this->tabj, $tablepatientida);
     
     
                $this->exN = $extmN;
            }
            if (($extmN != "") && ($extmY != "")) {
                $this->exY = $extmY;
                $this->exN = $extmN;
            }
      ///////////////////////////// Recoupe
            if (($recoupeY != "") && ($recoupeN == "")) {
     
                $qA = Doctrine::getTable('Anapath')->createQuery('a')
                   ->where('1 = 1')
                   ->addwhere('a.recoupe_extemp =?', $recoupeY)
                   ->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
                $this->tabj = array_merge($this->tabj, $tablepatientida);
                $this->recY = $recoupeY;
            }
            else if (($recoupeN != "") && ($recoupeY == "")) {
               $qA = Doctrine::getTable('Anapath')->createQuery('a')
                   ->where('1 = 1')
                   ->addwhere('a.recoupe_extemp =?', $recoupeN)
                   ->execute();
     
                $tablepatientida = array('null');
                foreach ($qA as $ana) {
                    $tablepatientida[] = $ana->getPatientId();
                }
                $this->tabj = array_merge($this->tabj, $tablepatientida);
     
     
                $this->recN = $recoupeN;
            }
            else if (($recoupeN != "") && ($recoupeY != "")) {
                $this->recY = $recoupeY;
                $this->recN = $recoupeN;
            }
     $this->patients = $q->execute();
            $this->getUser()->setAttribute("patientstable", $this->patients);
    Pouvez vous s'il vous plait me conseiller pour résoudre ce problème?

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 18
    Par défaut
    Je n'ai pas mis le nez dans ton code , mais si le problème vient de la requête, n'oublie pas la doc.
    Peut être que pourrait être la solution?

    Tu peux aussi vérifier ta requête avant l'exécution avec ou dans la barre de debug de symfony.

  5. #5
    Membre confirmé
    Inscrit en
    Mars 2011
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 65
    Par défaut
    Bonjour j'ai essayé à tester avec la requete
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    echo $q->getSqlQuery();
    et j'ai obtenue le résultat suivant lorsque je veux faire une recherche suivant deux critéres:
    SELECT a.id AS a__id, a.date AS a__date, a.poids AS a__poids, a.gleason AS a__gleason, a.gleason_max AS a__gleason_max, a.gleason_tertiaire AS a__gleason_tertiaire, a.stade_pt AS a__stade_pt, a.stade_pn AS a__stade_pn, a.nb_ganglions_total AS a__nb_ganglions_total, a.nb_ganglions_positif AS a__nb_ganglions_positif, a.rapportpt AS a__rapportpt, a.extemp AS a__extemp, a.res_extemp AS a__res_extemp, a.recoupe_extemp AS a__recoupe_extemp, a.pin AS a__pin, a.engainement_perinerveux AS a__engainement_perinerveux, a.statut_marge AS a__statut_marge, a.lobe_predominant AS a__lobe_predominant, a.diametre_max AS a__diametre_max, a.taille_marges AS a__taille_marges, a.gleason_marge AS a__gleason_marge, a.multifocal AS a__multifocal, a.ext_extracapsulaire AS a__ext_extracapsulaire, a.cote_gauche AS a__cote_gauche, a.cote_droit AS a__cote_droit, a.volume_tumoral AS a__volume_tumoral, a.mp_col AS a__mp_col, a.mp_base_dr AS a__mp_base_dr, a.mp_base_ga AS a__mp_base_ga, a.mp_postero_dr AS a__mp_postero_dr, a.mp_postero_ga AS a__mp_postero_ga, a.mp_apex_dr AS a__mp_apex_dr, a.mp_apex_ga AS a__mp_apex_ga, a.anterieur AS a__anterieur, a.posterieur AS a__posterieur, a.patient_id AS a__patient_id, a.created_at AS a__created_at, a.updated_at AS a__updated_at FROM anapath a WHERE 1 = 1 AND a.extemp = ?SELECT a.id AS a__id, a.date AS a__date, a.poids AS a__poids, a.gleason AS a__gleason, a.gleason_max AS a__gleason_max, a.gleason_tertiaire AS a__gleason_tertiaire, a.stade_pt AS a__stade_pt, a.stade_pn AS a__stade_pn, a.nb_ganglions_total AS a__nb_ganglions_total, a.nb_ganglions_positif AS a__nb_ganglions_positif, a.rapportpt AS a__rapportpt, a.extemp AS a__extemp, a.res_extemp AS a__res_extemp, a.recoupe_extemp AS a__recoupe_extemp, a.pin AS a__pin, a.engainement_perinerveux AS a__engainement_perinerveux, a.statut_marge AS a__statut_marge, a.lobe_predominant AS a__lobe_predominant, a.diametre_max AS a__diametre_max, a.taille_marges AS a__taille_marges, a.gleason_marge AS a__gleason_marge, a.multifocal AS a__multifocal, a.ext_extracapsulaire AS a__ext_extracapsulaire, a.cote_gauche AS a__cote_gauche, a.cote_droit AS a__cote_droit, a.volume_tumoral AS a__volume_tumoral, a.mp_col AS a__mp_col, a.mp_base_dr AS a__mp_base_dr, a.mp_base_ga AS a__mp_base_ga, a.mp_postero_dr AS a__mp_postero_dr, a.mp_postero_ga AS a__mp_postero_ga, a.mp_apex_dr AS a__mp_apex_dr, a.mp_apex_ga AS a__mp_apex_ga, a.anterieur AS a__anterieur, a.posterieur AS a__posterieur, a.patient_id AS a__patient_id, a.created_at AS a__created_at, a.updated_at AS a__updated_at FROM anapath a WHERE 1 = 1 AND a.recoupe_extemp = ?
    Je ne sais pas comment résoudre le probléme savant que j'ai entré deux critéres(extempo et recoupe).Pouvez vous me conseiller comment faire?
    Merci

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 18
    Par défaut
    Essaye de revoir ton algo.

    Construit d'abord toute ta requête

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    $qA = Doctrine::getTable('Anapath')->createQuery('a');
    if (($extmY != "") XOR ($extmN != ""))
    {
      if (($extmY != "")
      {
        $qA = $qA->addwhere('a.extemp =?', 1);
      }
      else
      {
        $qA = $qA->addwhere('a.extemp =?', 0);
      }
    }
    //etc avec $recoupeN et $recoupeY
    //puis
    $qA = $qA->execute();
    Cependant revoir tout le cheminement de ton algorithme pourrait pas mal, je pense que tu t'es peut être compliqué la vie.

  7. #7
    Membre confirmé
    Inscrit en
    Mars 2011
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 65
    Par défaut
    J'ai essayé de faire les modifications comme énoncé dans votre réponse comme ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
     
     
            ///////////////////////////// Extempo
           $qA = Doctrine::getTable('Anapath')->createQuery('a');
            if (($extmY != "") XOR ($extmN != "")) {
                if ($extmY != "") {
                    $qA = $qA->addwhere('a.extemp =?', $extmY);
                    $tablepatientida = array('null');
                    foreach ($qA as $ana) {
                        $tablepatientida[] = $ana->getPatientId();
                    }
                    $this->tabj = array_merge($this->tabj, $tablepatientida);
     
     
                    $this->exN = $extmY;
                } else {
                    $qA = $qA->addwhere('a.extemp =?', $extmN);
                    $tablepatientida = array('null');
                    foreach ($qA as $ana) {
                        $tablepatientida[] = $ana->getPatientId();
                    }
                    $this->tabj = array_merge($this->tabj, $tablepatientida);
     
     
                    $this->exN = $extmN;
                }
            }
    Lorsque j'essaye de faire une recherche suivant le paramétre exptempo alors aucun patient ne s'affiche alors qu'un certain nombre doit s'afficher.
    Comment je peux résoudre ceci?

Discussions similaires

  1. Problème dans un formulaire de connexion
    Par imalys dans le forum Forms
    Réponses: 1
    Dernier message: 31/01/2013, 09h14
  2. [ZF 1.10] Probléme dans le formulaires avec zend
    Par king_soft dans le forum Zend Framework
    Réponses: 3
    Dernier message: 16/12/2010, 15h23
  3. Réponses: 2
    Dernier message: 30/01/2010, 11h32
  4. [A-07] Problème dans un formulaire avec une requète de selection
    Par oraclus dans le forum Requêtes et SQL.
    Réponses: 7
    Dernier message: 24/12/2008, 00h06
  5. [MySQL] les apostrophe me cause un problème dans un formulaire
    Par pierrot10 dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 22/10/2005, 20h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo