Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework
Zend Framework Forum d'entraide sur la programmation PHP avec Zend Framework. Avant de poster -> FAQ ZF, Cours ZF
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 10/01/2011, 10h49   #1
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
Par défaut Erreur dans l'affichage

Bonjour,

je veux afficher les clients pour chaque employé,voila les codes:

Code :
1
2
3
4
5
6
7
 $client=new Client();
         $id_emp=$this->_request->getParam('id');
 
 
 
      $result = $client->fetchAll("SELECT client.nom_cl,client.prenom_cl  FROM vente,client WHERE client.id_cli=vente.id_cli  and vente.id_emp =".$id_emp);
			$this->view->empli= $result;
et voila ce qui me donne dans l'exécution:
Citation:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)' in C:\wamp\www\Opticien\library\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\Opticien\library\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\Opticien\library\Zend\Db\Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\Opticien\library\Zend\Db\Adapter\Abstract.php(468): Zend_Db_Statement->execute(Array) #3 C:\wamp\www\Opticien\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #4 C:\wamp\www\Opticien\library\Zend\Db\Table\Abstract.php(1505): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #5 C:\wamp\www\Opticien\library\Zend\Db\Table\Abstract.php(1321): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #6 C:\wamp\www\Opticien\application\default\controllers\StatisController.php(59): Zend_Db_Table_Abstract->fetchAll('SELECT clien in C:\wamp\www\Opticien\library\Zend\Db\Statement\Pdo.php on line 234
Ou est le problème donc?
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2011, 11h18   #2
Membre expérimenté
 
Avatar de manuscle
 
Homme Emmanuel Belair
Développeur informatique
Inscription : septembre 2004
Messages : 463
Détails du profil
Informations personnelles :
Nom : Homme Emmanuel Belair
Âge : 32
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Distribution

Informations forums :
Inscription : septembre 2004
Messages : 463
Points : 597
Points : 597
Bonjour,

Si tu essaie ceci:
Code :
1
2
 
$result = $client->getAdapter()->fetchAll("SELECT client.nom_cl,client.prenom_cl  FROM vente,client WHERE client.id_cli=vente.id_cli  and vente.id_emp =".$id_emp);
ça donne quoi?
__________________
Les idiots sont ceux qui ne posent jamais de question!
manuscle est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2011, 11h22   #3
Rédacteur/Modérateur
 
Avatar de MaitrePylos
 
Homme Gérard Ernaelsten
DBA & Dev PHP
Inscription : juin 2005
Messages : 3 174
Détails du profil
Informations personnelles :
Nom : Homme Gérard Ernaelsten
Âge : 39
Localisation : Belgique

Informations professionnelles :
Activité : DBA & Dev PHP
Secteur : Service public

Informations forums :
Inscription : juin 2005
Messages : 3 174
Points : 6 460
Points : 6 460
Ton message d'erreur te signale que tu as une erreur dans ta requête, essaye cette requête dans MySQL et voit ce qu'il retourne.
MaitrePylos est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2011, 12h19   #4
Membre à l'essai
 
Inscription : mars 2010
Messages : 213
Détails du profil
Informations forums :
Inscription : mars 2010
Messages : 213
Points : 23
Points : 23
J'ai appliqué votre code et voila ce qui m'a donné comme résultat:

Citation:
-Client(s):
Notice: Trying to get property of non-object in C:\wamp\www\Opticien\application\default\views\scripts\statis\selectionner.phtml on line 39

Notice: Trying to get property of non-object in C:\wamp\www\Opticien\application\default\views\scripts\statis\selectionner.phtml on line 39
et voila le code de selectionner.phtml:
Code :
<tr><td align="center">-Client(s):<?php echo $this->escape($this->empli->nom_cl).' '.  $this->escape($this->empli->prenom_cl); ?></td></tr>
king_soft est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2011, 10h03   #5
Membre expérimenté
 
Avatar de manuscle
 
Homme Emmanuel Belair
Développeur informatique
Inscription : septembre 2004
Messages : 463
Détails du profil
Informations personnelles :
Nom : Homme Emmanuel Belair
Âge : 32
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Distribution

Informations forums :
Inscription : septembre 2004
Messages : 463
Points : 597
Points : 597
C normal car la methode fetchAll de $db te retourne un tableau et non un objet
__________________
Les idiots sont ceux qui ne posent jamais de question!
manuscle est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 18h45.


 
 
 
 
Partenaires

Hébergement Web