Hello I need help with displaying data from 2 table.
So i Have 2 models:
//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();
}
}
and
//Nauczyciele.php
class Model_Nauczyciele extends Zend_Db_Table_Abstract
{
protected $_name = 'nauczyciele';
protected $_dependentTables = 'Model_Klasy';
}
In Controller have that code:
public function listaAction()
{
$modelLista = new Model_Klasy();
$this->view->listaKlas = $modelLista->listaKlas();
}
and in View this:
<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>
and partial file ListaKlas.phtml:
<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>
from Table Nauczyciele i want display 2 columns but dont know how. I know about method findParentRow but dont know where use it and how render data from second table. In my case i see only ID from table Klasy.