afficher le résultat d'une jointure
Bonsoir,
j'ai un problème d'affichage.
En fait j'ai fait une jointure entre deux classes mais je ne comprends pas très bien comment on peut afficher le résultat.
code model Reservations.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
| <?php
class Reservations extends Zend_Db_Table
{
protected $_name = 'reservations';
protected $_dependentTables = array("Clients");
protected $_referenceMap = array(
'Reporter' => array(
'columns' => 'id_client',
'refTableClass' => 'Clients',
'refcolumns' => 'id'
)
);
public function findReserv()
{
//$select = $this->getAdapter()->select()
$select = $this->select()
->setIntegrityCheck(false)
->from(array('r'=>$this->_name), array('dateCreation', 'dateArrivee', 'nbPersonnes', 'are'))
->join (array('c'=>'clients'), 'r.id_client = c.id', 'nom');
echo $select;
return $this->getAdapter()->fetchAll($select);
}
} |
code du contrôleur
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?php
class ReservationController extends Zend_Controller_Action
{
function indexAction()
{
$this->view->title = "Reservations";
$this->view->headTitle($this->view->title, 'PREPEND');
$reserv = new Reservations();
$this->view->reservations = $reserv->findReserv();
}
} |
et l'index.phtml
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
| <p><a href="<?php echo $this->url(array('controller'=>'reservation', 'action'=>'ajouter')); ?>">Ajouter une nouvelle reservation</a></p>
<table>
<tr>
<th>Date de creation</th>
<th>Date d'arrivee</th>
<th>Date de depart</th>
<th>Nombre de personne</th>
<th>Are</th>
</tr>
<?php foreach($this->reservations as $reservation) : ?>
<tr>
<td><?php echo $this->escape($reservation->dateCreation);?></td>
<td><?php echo $this->escape($reservation->dateArrivee);?></td>
<td><?php echo $this->escape($reservation->dateDepart);?></td>
<td><?php echo $this->escape($reservation->nbPersonnes);?></td>
<td><?php echo $this->escape($reservation->are);?></td>
<td><?php echo $this->escape($reservation->nom);?></td>
<td>
<a href="<?php echo $this->url(array('controller'=>'reservation', 'action'=>'modifier', 'id_reserv'=>$reservation->id_reserv));?>">Modifier</a>
<a href="<?php echo $this->url(array('controller'=>'reservation', 'action'=>'supprimer', 'id_reserv'=>$reservation->id_reserv));?>">Spprimer</a>
</td>
</tr>
<?php endforeach; ?>
</table> |
l'exécution de ce code me renvoie cette erreur pour chaque champs :
Code:
Notice: Trying to get property of non-object in C:\wamp\www\gestionStudios\application\views\scripts\reservation\index.phtml on line 12
quelqu'un pourrait-t'il m'aider?
Merci d'avance