Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour à tous voici mon probleme que je n'arrive pas à resoudre:
fichier dans mon model Loto.php
<?php Zend_Loader::loadClass("Zend_Db_Table_Abstract"); Zend_Loader::loadClass("Zend_Db_Table_Row_Abstract"); class Loto extends Zend_Db_Table_Abstract { protected $_name = 'loto'; protected $_rowClass = 'loto_Row'; public function newRow($obj = null) { if ($obj) { if (is_object($obj)) $obj = get_object_vars($obj); $row = $this->createRow($obj); } else { $row = $this->createRow(); } return $row; } } Class Loto_Row extends Zend_Db_Table_Row_Abstract { }
fichier dans mon controlleur LotoController.php
function ajouterAction() { $this->view->title = "Voici les 10 derniers résultats du loto"; $table = new Loto(); $lastOperation=$table->fetchAll("1", 'numero1 DESC', 0, 10); $this->view->historique = $lastOperation->fetchAll(); }
fichier dans ma vue ajouter.phtml
<html> <head> <title></title> </head> <body> <?php foreach ($this->historique as $lastOperation) { ?> <b><?php echo $lastOperation; ?> </b>- <hr/> <?php } ?> </body> </html>
mon erreur est la suivante :
Fatal error: Call to undefined method Zend_Db_Table_Rowset::fetchAll() in G:\wamp\www\Trouverunnumero\application\controllers\LotoController.php on line 28
cette ligne est la suivante : $this->view->historique = $lastOperation->fetchAll();
J'ai fais le tuto avec les albums etc... Mais à par selectionner tous les tuples d'une table je n'arrive pas a en afficher que 10 par exemple.
Peut etre quand voyant mon code vous allez vous mettre les mains aux yeux mais j'espere que vous pourrez m'aider.
Voila merci d'avance
Hors ligne
$lastOperation=$table->fetchAll("1", 'numero1 DESC', 0, 10); $this->view->historique = $lastOperation->fetchAll();
2 fetchAll() à la suite ça le fait pas ... :
$lastOperation=$table->fetchAll("1", 'numero1 DESC', 0, 10); $this->view->historique = $lastOperation;
Hors ligne
Merci de votre aide.
Bon maintenant il me met l'erreur suivante :
Catchable fatal error: Object of class Zend_Db_Table_Rowset could not be converted to string in D:\wamp\www\Trouverunnumero\application\controllers\LotoController.php on line 27
Cette ligne correspond à :
$lastOperation=$table->fetchAll("1", 'n1 DESC', 0, 10);
une idée?
Hors ligne
j'ai trouvé :
J'ai fais ca dans le .phtml
<?php if ($this->historique instanceof Zend_Db_Table_Rowset){ $lastOperation = $this->historique; foreach ($lastOperation as $log){ echo ' <tr> <td>'.$log->n1.'</td> </tr> '; } }
?>
Hors ligne