Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > symfony
symfony Forum d'entraide sur le framework PHP symfony. Avant de poster : cours symfony et FAQ symfony
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/09/2011, 10h58   #1
Invité de passage
 
Inscription : mars 2011
Messages : 60
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 60
Points : 1
Points : 1
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 :
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 :
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.
farhaenis est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/09/2011, 12h57   #2
Futur Membre du Club
 
Inscription : juillet 2010
Messages : 18
Détails du profil
Informations forums :
Inscription : juillet 2010
Messages : 18
Points : 18
Points : 18
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()).
thomas974 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/09/2011, 15h25   #3
Invité de passage
 
Inscription : mars 2011
Messages : 60
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 60
Points : 1
Points : 1
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 :
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?
farhaenis est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/09/2011, 08h28   #4
Futur Membre du Club
 
Inscription : juillet 2010
Messages : 18
Détails du profil
Informations forums :
Inscription : juillet 2010
Messages : 18
Points : 18
Points : 18
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.
thomas974 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/09/2011, 11h40   #5
Invité de passage
 
Inscription : mars 2011
Messages : 60
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 60
Points : 1
Points : 1
Bonjour j'ai essayé à tester avec la requete
Code :
echo $q->getSqlQuery();
et j'ai obtenue le résultat suivant lorsque je veux faire une recherche suivant deux critéres:
Citation:
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
farhaenis est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/09/2011, 11h59   #6
Futur Membre du Club
 
Inscription : juillet 2010
Messages : 18
Détails du profil
Informations forums :
Inscription : juillet 2010
Messages : 18
Points : 18
Points : 18
Essaye de revoir ton algo.

Construit d'abord toute ta requête

Code :
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.
thomas974 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/09/2011, 12h52   #7
Invité de passage
 
Inscription : mars 2011
Messages : 60
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 60
Points : 1
Points : 1
J'ai essayé de faire les modifications comme énoncé dans votre réponse comme ceci:
Code :
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?
farhaenis est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h37.


 
 
 
 
Partenaires

Hébergement Web