Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework > Zend_Db
Zend_Db Forum d'entraide pour le composant Zend_Db du Zend Framework (création de requêtes, abstraction, ORM etc.). Avant de poster -> FAQ Zend_Db.
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 20/11/2007, 00h02   #1
Invité de passage
 
Inscription : avril 2005
Messages : 9
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 9
Points : 1
Points : 1
Par défaut Zend et ajouter album

Hello,

Beaucoup de questions autour du tutorial Zend mais je n'y ai pas vu la mienne.
Donc voilà la situation :

--> J'affiche correctement les 2 albums comme dans le tutorial.
--> j'ai activé le pdo_mysql.
--> J'ai mis le output_buffering de php.ini sur ON

Dès que je clique sur "Ajouter un nouvel album", les 2 champs apparaissent mais quand je valide :

Citation:
Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in C:\Wamp\www\zf-tutorial\application\controllers\IndexController.php, line 2' in C:\Wamp\www\zf-tutorial\library\Zend\Controller\Response\Abstract.php:265 Stack trace: #0 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Response\Abstract.php(131): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action\Helper\Redirector.php(192): Zend_Controller_Response_Abstract->setRedirect('/zf-tutorial/', 302) #2 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action\Helper\Redirector.php(348): Zend_Controller_Action_Helper_Redirector->_redirect('/zf-tutorial/') #3 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action\Helper\Redirector.php(430): Zend_Controller_Action_Helper_Redirector->setGotoUrl('/', Array) #4 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action.php(667): Zend_Controller_Action_Helper_Redirector->gotoUrl('/', Array) #5 C:\Wamp\www\z in C:\Wamp\www\zf-tutorial\library\Zend\Controller\Response\Abstract.php on line 265
Et pourtant l'ajout marche !?!


Même chose quand je valide la modification :
Citation:
Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in C:\Wamp\www\zf-tutorial\application\controllers\IndexController.php, line 2' in C:\Wamp\www\zf-tutorial\library\Zend\Controller\Response\Abstract.php:265 Stack trace: #0 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Response\Abstract.php(131): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action\Helper\Redirector.php(192): Zend_Controller_Response_Abstract->setRedirect('/zf-tutorial/', 302) #2 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action\Helper\Redirector.php(348): Zend_Controller_Action_Helper_Redirector->_redirect('/zf-tutorial/') #3 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action\Helper\Redirector.php(430): Zend_Controller_Action_Helper_Redirector->setGotoUrl('/', Array) #4 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action.php(667): Zend_Controller_Action_Helper_Redirector->gotoUrl('/', Array) #5 C:\Wamp\www\z in C:\Wamp\www\zf-tutorial\library\Zend\Controller\Response\Abstract.php on line 265
Par contre, quand je clique sur le lien supprimer :
Citation:
Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::supprimerAction() does not exist and was not trapped in __call()' in C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action.php:480 Stack trace: #0 [internal function]: Zend_Controller_Action->__call('supprimerAction', Array) #1 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action.php(497): IndexController->supprimerAction() #2 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(238): Zend_Controller_Action->dispatch('supprimerAction') #3 C:\Wamp\www\zf-tutorial\library\Zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 C:\Wamp\www\zf-tutorial\index.php(31): Zend_Controller_Front->dispatch() #5 {main} thrown in C:\Wamp\www\zf-tutorial\library\Zend\Controller\Action.php on line 480
Pas facile le MVC !

Merci de votre aide !
xev74 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/11/2007, 18h22   #2
Membre régulier
 
Inscription : juillet 2002
Messages : 149
Détails du profil
Informations forums :
Inscription : juillet 2002
Messages : 149
Points : 80
Points : 80
Poste aussi ton code ça aidera beaucoup. Sinon on va devoir faire des suppositions.
SQUAL est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/11/2007, 09h58   #3
Invité de passage
 
Inscription : avril 2005
Messages : 9
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 9
Points : 1
Points : 1
Voici le code.
Je tiens à préciser que je suis à la lettre le tutorial de Zend Framework sur PHP MVC, dispo sur le site Web de Developpez.com :

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
class IndexController extends Zend_Controller_Action
{
	function init()
	{
	$this->initView();
	Zend_Loader::loadClass('Album');
	$this->view->baseUrl = $this->_request->getBaseUrl();
	$this->view->user = Zend_Auth::getInstance()->getIdentity();
	}
 
	function indexAction()
	{
	$this->view->title = "Mes albums";
	$album = new Album();
	$this->view->albums = $album->fetchAll();
	}
 
	function ajouterAction()
	{
	$this->view->title = "Ajouter un nouvel album";
	if ($this->_request->isPost()) {
		Zend_Loader::loadClass('Zend_Filter_StripTags');
		$filter = new Zend_Filter_StripTags();
		$artist = $filter->filter($this->_request->getPost('artist'));
		$artist = trim($artist);
		$title = trim($filter->filter($this->_request->getPost('title')));
			if ($artist != '' && $title != '') {
			       $data = array(
			        'artist' => $artist,
				'title' => $title,
				);
				$album = new Album();
				$album->insert($data);
				$this->_redirect('/');
				return;
			}
		}
		// set up an "empty" album
		$this->view->album = $album->createRow();
		// additional view fields required by form
		$this->view->action = 'ajouter';
		$this->view->buttonText = 'Ajouter';
	}
 
	function modifierAction()
	{
		$this->view->title = "Modifier l'album";
		$album = new Album();
		if ($this->_request->isPost()) {
			Zend_Loader::loadClass('Zend_Filter_StripTags');
			$filter = new Zend_Filter_StripTags();
			$id = (int)$this->_request->getPost('id');
			$artist = $filter->filter($this->_request->getPost('artist'));
			$artist = trim($artist);
		      $title = trim($filter->filter($this->_request->getPost('title')));
			if ($id !== false) {
				if ($artist != '' && $title != '') {
					$data = array(
					'artist' => $artist,
					'title' => $title,);
					$where = 'id = ' . $id;
					$album->update($data, $where);
					$this->_redirect('/');
					return;
				} 
				else {
				    $this->view->album = $album->fetchRow('id='.$id);
				}
			}
		} 
		else {
			// album id should be $params['id']
			$id = (int)$this->_request->getParam('id', 0);
			if ($id > 0) {
				$this->view->album = $album->fetchRow('id='.$id);
			}
		}
		// additional view fields required by form
		$this->view->action = 'modifier';
		$this->view->buttonText = 'Mettre à jour';
		}
	}
 
	function supprimerAction()
	{
		$this->view->title = "Supprimer l'album";
		$album = new Album();
		if ($this->_request->isPost()) {
			Zend_Loader::loadClass('Zend_Filter_Alpha');
			$filter = new Zend_Filter_Alpha();
			$id = (int)$this->_request->getPost('id');
			$del = $filter->filter($this->_request->getPost('del'));
			if ($del == 'Oui' && $id > 0) {
				$where = 'id = ' . $id;
				$rows_affected = $album->delete($where);
			}
		}	
		else {
			$id = (int)$this->_request->getParam('id');
			if ($id > 0) {
				// only render if we have an id and can find the album.
				$this->view->album = $album->fetchRow('id='.$id);
				if ($this->view->album->id > 0) {
					// render template automatically
					return;
				}
			}
		}
		// redirect back to the album list unless we have rendered the view
		$this->_redirect('/');
	}
 
	function preDispatch()
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->_redirect('auth/login');
}
}
xev74 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/11/2007, 09h17   #4
Invité régulier
 
Inscription : octobre 2006
Messages : 14
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 14
Points : 8
Points : 8
Le code me semble juste...
Peux tu nous donner la version de ton php et ton apache s'il te plait
slasch est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/11/2007, 10h44   #5
Membre du Club
 
Développeur Web
Inscription : décembre 2005
Messages : 110
Détails du profil
Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : décembre 2005
Messages : 110
Points : 45
Points : 45
Peux-tu poster également ton index.php et ta vue ?

En fait, tu as du préciser un header quelque part et ça doit entrer en conflit avec un header que Zend essaye de préciser aussi.
fadeninev est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/11/2007, 17h44   #6
Invité de passage
 
Inscription : avril 2005
Messages : 9
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 9
Points : 1
Points : 1
Mouais ...
Un collègue vient de faire le même tutorial que moi mais celui de la version anglaise et le sien marche nickel.
J'ai donc récupérer le sien et à première vue, les quelques modifications ne concerne pas ce que tu évoques.

en tout cas, ça marche, faut juste que je relise un peu tout ça pour comprendre exactement le schmilblik.

Merci !
xev74 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/11/2007, 19h54   #7
Invité régulier
 
Inscription : octobre 2006
Messages : 14
Détails du profil
Informations forums :
Inscription : octobre 2006
Messages : 14
Points : 8
Points : 8
Une fois que tu aura trouvé ton erreur, n'hesite pas à nous la montrer histoire qu'on fasse pas la même erreur... ^^
slasch est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/08/2009, 18h10   #8
Invité de passage
 
Inscription : décembre 2005
Messages : 2
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 2
Points : 2
Points : 2
Envoyer un message via MSN à gontran6
Un petit mot sur ce tutoriel.
Quel est l'intérêt de faire une traduction d'un tutoriel si c'est pour y déposer des coquilles que l'auteur original s'est abstenu de mettre?
J'ai suivi ce tutoriel et ma foi c'est pas une mince affaire. En effet un tutoriel c'est avant tout consulté et suivi par des débutants en la matière et ici la matière c'est pas du gâteau. Donc un message à l'auteur de ce tuto version FR, si c'est pour reprendre un tutoriel et le traduire merci de le laisser tel quel et gardez vous de ne pas y mettre votre grain de sel ça évite de perdre du temps sur des erreurs qui freinent l'apprentissage.
gontran6 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 16h18.


 
 
 
 
Partenaires

Hébergement Web