[0.8] Problème avec la recherche MVC (Tuto d'Akrabat)
Bonjours a tous
voila je me suis lancé dans l'aventure Zend Framework en étudiant à fond le tutorial de Akrabat
puis je me suis mis à le pressonnalisé afin d'en faire un petit gestionnaire de CV histoire de me faire les dents
seulement j'ai un gros problème avec la fonctionnalité recherche de CV
j'explique : j'ai rajouter une fonction " function searchAction()" au controleur
que j'appél via un lien sur la vue "indexIndex.tpl.php"
Code:
<p><a href="/alitech/index/search">Rechercher un CV</p>
j'ai egalement crée une vue spécifique à la recherche "indexSearch.tpl.php"
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
| <h1><?php echo $this->escape($this->title); ?></h1>
<table>
<form action="/alitech/index/search" method="POST">
<tr><td>Nom</td><td><input type="text" name="nom"></td></tr>
<tr><td></td><td><input type="submit" value="OK"></td> </tr>
</form>
</table>
<table>
<tr>
<th>Nom</th>
<th>Prenom</th>
<th> </th>
</tr>
<?php foreach($this->cv as $cv) : ?>
<tr>
<td><?php echo $this->escape($cv->nom); ?></td>
<td><?php echo $this->escape($cv->prenom); ?></td>
<td>
<a href="/alitech/index/edit/id/<?php echo $cv->id; ?>"
>Editer</a>
<a href="/alitech/index/delete/id/<?php echo $cv->id; ?>"
>Supprimer</a>
</td>
</tr>
<?php endforeach; ?>
</table> |
seulement je n'arrive pas faire fonctionner la fonction Search dont voici le code
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
| function searchAction()
{
$view = Zend::registry('view');
$view->title = "Mes CV";
$cv = new cv();
$view->cv = $cv->fetchAll();
$view->actionTemplate = 'indexSearch.tpl.php';
$this->_response->setBody($view->render('site.tpl.php'));
$cv = new cv();
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
$post = Zend::registry('post');
$nom = $post->getAlpha('nom');
if ($nom != ''){
//$view->cv = $cv->find($nom);
// $where = 'nom = '. $nom;
// $db = new cv();
/* $select = $db->select();
$select->from('cv','*');
$select->where('nom = ?',$nom);
*/
// $view->cv = $DB->fetchAll($select);
//$where = "nom = ?". $nom;
//$view->cv = $cv->fetchRow($nom, $where);
}
//$view->actionTemplate = 'indexIndex.tpl.php';
//$this->_response->setBody($view->render('site.tpl.php'));
}else{
$view->action = 'edit';
$view->buttonText = 'Search';
$view->actionTemplate = 'indexSearch.tpl.php';
$this->_response->setBody($view->render('site.tpl.php'));
}
}
} |
vous voyez la partie (après récupération du "post") qui est en commentaire ce sont mes différentes expériences d'hier...je sais le désespoir génére un drôle de code 8O
et résultat :bug:
Donc un petit coup de pouce SVP merci d'avance:D
et bon code à tous