Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
voila j'ai un probleme avec ma requette delete ca ne marche pas, elle renvoi une erreur quand je fais ceci
$paiement = new Paiement(); $where = 'paiement.NUMPAIEMENT = cohtion.NUMPAIEMENT AND cohtion.NUMPERSONNE='.$id; $paiement->delete($where);
si qlq un a une idee, merci.
Dernière modification par Mr.MoOx (30-10-2009 22:53:05)
Hors ligne
@sm : juste pour info (je pense que Mr Moox a raison pour l'explication) quelle erreur est renvoyée ?
Hors ligne
la suivante.
Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'cohtion.NUMPAIEMENT' in 'where clause'' in C:\wamp\www\SamaxSoft\library\Zend\Db\Statement\Pdo.php:238 Stack trace: #0 C:\wamp\www\SamaxSoft\library\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 C:\wamp\www\SamaxSoft\library\Zend\Db\Adapter\Abstract.php(433): Zend_Db_Statement->execute(Array) #2 C:\wamp\www\SamaxSoft\library\Zend\Db\Adapter\Pdo\Abstract.php(230): Zend_Db_Adapter_Abstract->query('DELETE FROM `pa...', Array) #3 C:\wamp\www\SamaxSoft\library\Zend\Db\Adapter\Abstract.php(580): Zend_Db_Adapter_Pdo_Abstract->query('DELETE FROM `pa...') #4 C:\wamp\www\SamaxSoft\library\Zend\Db\Table\Abstract.php(1010): Zend_Db_Adapter_Abstract->delete('paiement', 'paiement.NUMPAI...') #5 C:\wamp\www\SamaxSoft\application\controllers\AdminController.php(125): Zend_Db_Table_Abstract->delete('paiement.NUMPAI...') #6 C:\wamp\www\SamaxSoft\library\Zend\Controller\Action.php(503): in C:\wamp\www\SamaxSoft\library\Zend\Db\Statement\Pdo.php on line 238
Hors ligne
C'est certainement ca, mais il serait intéressant de dumper la requete SQL pour voir exactement
Hors ligne
voila j'ai reussi a evité l'erreur en fusant comme ceci
$paiement = new Paiement(); $sql = 'select NUMPAIEMENT from cohtion where NUMPERSONNE = ' . $id; $result = (int)$paiement->fetchRow($sql); $where = 'NUMPAIEMENT = ' . $result; $paiement->delete($where);
mais je vois que mon enregistrement n'a pas etait supprimer dans ma table paiement
Dernière modification par Mr.MoOx (23-10-2009 16:02:57)
Hors ligne
Malheureusement je pense que la ligne suivante ne doit pas te retourner ce que tu veux
$result = (int)$paiement->fetchRow($sql);
Essayes
$result = (int)$paiement->fetchRow($sql)->NUMPAIEMENT;
Petite remarque tu devrais utiliser la notation des requêtes préparés
Ex:
$paiement->delete(array('NUMPAIEMENT = ?' => $result));
C'est plus sécurisé car cela converti bien la valeur en mettant ce qu'il faut selon le type (quote par exemple etc).
http://julien-pauli.developpez.com/tuto … ge=zend-db
Hors ligne
Mr.MoOx j'ai essai vote suggetion mais ca n'aller pas et apres qlq modification la suppression marche mais a chaque fois c'est la premiere ligne de ma table paiement qui est supprimé. en fait la suppresion se fais sur 3 table
$cohtion = new Cohtion(); $sql = 'select NUMPAIEMENT from cohtion where NUMPERSONNE = ' . $id; $result = (int)$cohtion->fetchRow($sql)->NUMCOHTION; $where = 'NUMPERSONNE = ' . $id; $cohtion->delete($where); $personne = new Personne(); $where = 'NUMPERSONNE = ' . $id; $personne->delete($where); $paiement = new Paiement(); $where = 'NUMPAIEMENT = ' . $result; $paiement->delete($where);
Dernière modification par sm (27-10-2009 22:28:54)
Hors ligne
c'est réglé, voila comment j'ai fait.
merci.
$cohtion = new Cohtion(); $result = $cohtion->fetchRow('NUMPERSONNE = ' . $id)->NUMPAIEMENT; $where = 'NUMPERSONNE = ' . $id; $cohtion->delete($where); $personne = new Personne(); $where = 'NUMPERSONNE = ' . $id; $personne->delete($where); $paiement = new Paiement(); $where = 'NUMPAIEMENT = ' . $result; $paiement->delete($where);
Hors ligne