Bonjour J'ai besoin d'aide pour afficher les données de 2 tables.Comment afficher les données de 2 tables connexes dans Zend Framework
j'ai donc 2 modèles:
//Klasy.php
class Model_Klasy extends Zend_Db_Table_Abstract
{
protected $_name = 'klasy';
protected $_primary = 'id';
protected $_referenceMap = array(
'Nauczyciele' => array(
'columns' => array('Wychowawca'),
'refTableClass' => 'Model_Nauczyciele',
'refColumns' => array('id')
)
);
public function listaKlas()
{
$dane = $this->select();
return $this->fetchAll();
}
}
et
//Nauczyciele.php
class Model_Nauczyciele extends Zend_Db_Table_Abstract
{
protected $_name = 'nauczyciele';
protected $_dependentTables = 'Model_Klasy';
}
Dans Controller ont ce code:
public function listaAction()
{
$modelLista = new Model_Klasy();
$this->view->listaKlas = $modelLista->listaKlas();
}
et Voir ceci:
<b>Lista Klas:</b>
<table>
<tr>
<th>Klasa</th>
<th>Rok rozpoczęcia nauki</th>
<th>Wychowawca</th>
</tr>
<tr><?php echo $this->partialLoop('partials/ListaKlas.phtml', $this->listaKlas); ?></tr>
</table>
et ListaKlas.phtml de fichiers partiels:
<tr>
<td><?php echo $this->nazwa; ?></td>
<td><?php echo $this->rok_rozpoczecia; ?></td>
<td>
<?php
echo $this->Wychowawca;
?>
</td>
<td style="width: 5%">
<a href="<?php echo $this->baseUrl() . '/klasy/edytuj/id/';
echo $this->id ;?>">Edytuj
</a>
</td>
<td style="width: 5%">
<a href="<?php echo $this->baseUrl() . '/klasy/usun/id/';
echo $this->id ;?>">Usuń
</a>
</td>
</tr>
du tableau Nauczyciele je veux afficher 2 colonnes, mais ne savent pas comment. Je connais la méthode findParentRow mais ne sais pas où l'utiliser et comment rendre les données de la deuxième table. Dans mon cas, je ne vois que l'ID de la table Klasy.
Merci pour votre information. Je dois maintenant en lire plus à ce sujet. Dans un livre à partir de laquelle j'ai appris ZF thet écrire cela comme dans mon cas. Je dois le changer. – WooCaSh
Je change de modèle pour cette méthode que tu me montres. Merci pour l'aide – WooCaSh