Salut a tous voila j'ai realiser le tuto Débuter avec Zend Framework voila j'arrive a afficher le controller et mon views fonctionne affiche bdd Album mais quand il s'agit d'ajouter et modifier des nouveaux albums
cela ne fonctionne pas pourtant j'ai bien suivi et ajouter tout dans les views:
voici mon
controller :
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
<?php
 
class IndexController extends Zend_Controller_Action
{
 
    public function init()
    {
        /* Initialize action controller here */
    }
 
    public function indexAction()
    {
        $this->view->title = "Mes Albums";
    $this->view->headTitle($this->view->title, 'PREPEND');
    $albums = new Model_DbTable_Albums();
    $this->view->albums = $albums->fetchAll();
    }
 
    public function addAction()
    {
        $this->view->title = "Ajouter un nouvel album";
    $this->view->headTitle($this->view->title, 'PREPEND');
 
    $form = new Form_Album();
    $form->envoyer->setLabel('Ajouter');
    $this->view->form = $form;
 
    if ($this->getRequest()->isPost()) {
        $formData = $this->getRequest()->getPost();
        if ($form->isValid($formData)) {
            $artiste = $form->getValue('artiste');
            $titre = $form->getValue('titre');
            $albums = new Model_DbTable_Albums();
            $albums->ajouterAlbum($artiste, $titre);
 
            $this->_redirect('/');
        } else {
            $form->populate($formData);
        }
    }
    }
 
    public function editAction()
    {
        $this->view->title = "Modifier l'album";
    $this->view->headTitle($this->view->title, 'PREPEND');
 
    $form = new Form_Album();
    $form->envoyer->setLabel('Sauvegarder');
    $this->view->form = $form;
 
    if ($this->getRequest()->isPost()) {
        $formData = $this->getRequest()->getPost();
        if ($form->isValid($formData)) {
            $id = (int)$form->getValue('id');
            $artiste = $form->getValue('artiste');
            $titre = $form->getValue('titre');
            $albums = new Model_DbTable_Albums();
            $albums->modifierAlbum($id, $artiste, $titre);
 
            $this->_redirect('/');
        } else {
            $form->populate($formData);
        }
    } else {
        $id = $this->_getParam('id', 0);
        if ($id > 0) {
            $albums = new Model_DbTable_Albums();
            $form->populate($albums->obtenirAlbum($id));
        }
    }
    }
 
    public function deleteAction()
    {
        $this->view->title = "Supprimer l'album";
    $this->view->headTitle($this->view->title, 'PREPEND');
 
    if ($this->getRequest()->isPost()) {
        $supprimer = $this->getRequest()->getPost('supprimer');
        if ($supprimer == 'Oui') {
            $id = $this->getRequest()->getPost('id');
            $albums = new Model_DbTable_Albums();
            $albums->supprimerAlbum($id);
        }
 
        $this->_redirect('/');
    } else {
        $id = $this->_getParam('id', 0);
        $albums = new Model_DbTable_Albums();
        $this->view->album = $albums->obtenirAlbum($id);
    }
    }
 
 
}
application.ini
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
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "Europe/Paris"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
resources.frontController.params.displayExceptions = 0
 
[staging : production]
resources.db.adapter = "MYSQLI"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "zftutorial"
resources.db.params.charset = "utf8"
resources.db.isDefaultTableAdapter = true
 
 
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
 
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
 
;
resources.db.adapter = "MYSQLI"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "zftutorial"
resources.db.params.charset = "utf8"
resources.db.isDefaultTableAdapter = true
ainsi que le Bootstrap:
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
<?php
 
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
 
 
protected function _initAutoload()
	{
		$moduleLoader = new Zend_Application_Module_Autoloader(array(
			'namespace' => '',
			'basePath' => APPLICATION_PATH));
		return $moduleLoader;
	}
 
protected function _initViewHelpers()
{
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView();
    $view->doctype('XHTML1_STRICT');
    $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
    $view->headTitle()->setSeparator(' - ');
    $view->headTitle(' Tutoriel Zend Framework');
}
}
voila si vous voulez plus de renseignement il ya pas de soucis (merci d'avance votre helpers)