當我使用的foreach顯示在底部的我的價值,它給我一個假值 控制器:CakePHP的的foreach
public function index_hote() {
$this->Reservation->recursive = 1;
$this->loadModel("Bien");
$biens=$this->Bien->find('first',array('conditions'=>array("Bien.idBien =idBien")));
$reservations=$this->Reservation- >find('first',
array('conditions'=>array('Reservation.idBien'=> $biens['Bien'] ['idBien'])));
Debugger::dump($reservations['Reservation']);
$this->paginate('Reservation');
$this->set('reservations', $reservations['Reservation']);
}
在視圖:
<?php foreach ($reservations as $reservation): ?>
<tr>
<?php echo h($reservation) ?>
<td><?php echo h($reservation['dateReserDu']); ?> </td>
<td><?php echo h($reservation['dateReserAu']); ?> </td>
<td><?php echo h($reservation['montantAPaye']); ?> </td>
<td><?php echo h($reservation['etatReservation']); ?> </td>
</tr>
<?php endforeach; ?>
當我調試它顯示我正確的價值(做Debugger::dump($reservations['Reservation']);
後的PIC):
但在表它顯示我一個假值:
當我做<?php echo h($reservation) ?>
它顯示我正確的價值,但是當我添加屬性如h($reservation['dateReserDu']); ?>
這是行不通的PLZ爲什麼?我什麼時候可以做?
請告訴我們你剛纔'調試($預約);'歡呼 –
陣列(' Reservation'=> array('idReser'=>'1', 'dateReserDu'=>'2016-04-23','dateReserAu'=>'2016-04-27', 'montantAPaye'=>'500 ','etatReservation'=>'attente', 'iddev'=>'0','idBien'=>'9', 'id'=>'24'), \t'Personne'=> array('login'=>'*****','id'=>'24','designation'=>'client','nom'=>'mohamed',' prenom」 => 'jmaa', 'dateNaiss'=> '1991年7月22日', \t \t '住址'=> '芸香巴黎', \t \t 'telFixe'=> '26119945', \t \t 'telMobile1'=> '95632114', \t \t 'telMobile2'=> '98745213', \t \t '電子郵件'=> '[email protected]', \t \t 'MDP'=> '26111991', \t \t 'lienPhotoPersonnel'=> 'sou.jpg', \t \t 'idVille'=> '14' \t) \t ) – wah