IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Zend_Db PHP Discussion :

Zend et ajouter album


Sujet :

Zend_Db PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2005
    Messages : 18
    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 :

    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 :
    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 :
    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 !

  2. #2
    Membre très actif
    Inscrit en
    Juillet 2002
    Messages
    190
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 190
    Par défaut
    Poste aussi ton code ça aidera beaucoup. Sinon on va devoir faire des suppositions.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2005
    Messages : 18
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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');
    }
    }

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 14
    Par défaut
    Le code me semble juste...
    Peux tu nous donner la version de ton php et ton apache s'il te plait

  5. #5
    Membre confirmé
    Profil pro
    Développeur Web
    Inscrit en
    Décembre 2005
    Messages
    110
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Décembre 2005
    Messages : 110
    Par défaut
    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.

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2005
    Messages : 18
    Par défaut
    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 !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. ajouter albums galerie jquery
    Par arnlig3550 dans le forum jQuery
    Réponses: 0
    Dernier message: 15/03/2012, 17h58
  2. Zend form, ajouter un caractère derrière un input text
    Par supertotal dans le forum Zend_Form
    Réponses: 7
    Dernier message: 24/02/2012, 18h00
  3. Réponses: 2
    Dernier message: 16/12/2009, 16h07
  4. Ajout d'une autre librairie autre que zend
    Par Jcpan dans le forum MVC
    Réponses: 1
    Dernier message: 27/11/2009, 08h34
  5. [Zend Neon beta] Ajouter un raccourci
    Par FredPont dans le forum Zend Studio
    Réponses: 1
    Dernier message: 22/05/2008, 11h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo