Cakephp foreach condition

*爱你&永不变心* 提交于 2020-01-11 13:01:12

问题


i would have to show the table of reservation of 3 biens it should show me 3 line of 3 reservation but it show me just one line in the controllers

      public function index_hote() {
    $this->Reservation->recursive = 1;
    $this->loadModel("BiensPersonne");
   if($this->Session->read('Auth.User.0.Personne.id')){
        $options = $this->BiensPersonne->findByPersonneId($this->Session-     >read('Auth.User.0.Personne.id')); 
    $this->loadModel("Personne");

$biens=$this->Personne->findById( $options['BiensPersonne']['personne_id']);    
 foreach ($biens['Bien'] as $bien) {
 $reservations=$this->Reservation-  >find('all',array('conditions'=>array('Reservation.idBien'=> $bien['idBien'])));
 Debugger::dump($reservations);
$this->paginate('Reservation');
$this->set('reservations', $reservations);
 }}}

in the view

 <?php foreach ($reservations as $reservation): ?> <tr>
<td><?php echo h($reservation['Reservation']['dateReserDu']); ?></td>
    <td><?php echo h($reservation['Reservation']['dateReserAu']); ?> </td>
    <td><?php echo h($reservation['Reservation']['montantAPaye']); ?></td>
    <td><?php echo h($reservation['Reservation']['etatReservation']); ?>   </td>
   </tr> <?php endforeach ?>

if i doo debug resevation it show me this

       array(
     (int) 0 => array(
    'Reservation' => array(
        'idReser' => '1',
        'dateReserDu' => '2016-04-23',
        'dateReserAu' => '2016-04-27',
        'montantAPaye' => '500',
        'etatReservation' => 'attente',
        'iddev' => '0',
        'idBien' => '9',
        'id' => '24'
    ),
    'Personne' => array(
        'login' => '*****',
        'id' => '24',
        'designation' => 'client',
        'nom' => 'mohamed',
        'prenom' => 'jmaa',
        'dateNaiss' => '1991-07-22',
        'adresse' => 'rue paris',
        'telFixe' => '26119945',
        'telMobile1' => '95632114',
        'telMobile2' => '98745213',
        'email' => 'wahibaml@gmail.com',
        'mdp' => '26111991',
        'lienPhotoPersonnel' => 'sou.jpg',
        'idVille' => '14'
    ),
    'Device' => array(
        'iddev' => null,
        'nomdev' => null,
        'logodev' => null,
        'coefficient' => null
    ),
    'Bien' => array(
        'idBien' => '9',
        'designBien' => 'maison pour couple',
        'aPropos' => 'grand maison',
        'capaciteAccueil' => '5',
        'nbSalleBain' => '1',
        'nbChambre' => '3',
        'nbLits' => '5',
        'description' => 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh',
        'adresse' => 'rue ladikiya',
        'immeuble' => 'zitouna',
        'affichable' => false,
        'affichablePageAccueil' => false,
        'idtypelogement' => '1',
        'idVille' => '1',
        'idPays' => '1',
        'idTypeBien' => '1',
        'posLat' => '36.4236',
        'posLong' => '10.6088'
    )
       )
       )
      array(
       (int) 0 => array(
    'Reservation' => array(
        'idReser' => '3',
        'dateReserDu' => '2016-04-08',
        'dateReserAu' => '2016-04-29',
        'montantAPaye' => '700',
        'etatReservation' => 'attente',
        'iddev' => '0',
        'idBien' => '21',
        'id' => '24'
    ),
    'Personne' => array(
        'login' => '*****',
        'id' => '24',
        'designation' => 'client',
        'nom' => 'mohamed',
        'prenom' => 'jmaa',
        'dateNaiss' => '1991-07-22',
        'adresse' => 'rue paris',
        'telFixe' => '26119945',
        'telMobile1' => '95632114',
        'telMobile2' => '98745213',
        'email' => 'wahibaml@gmail.com',
        'mdp' => '26111991',
        'lienPhotoPersonnel' => 'sou.jpg',
        'idVille' => '14'
    ),
    'Device' => array(
        'iddev' => null,
        'nomdev' => null,
        'logodev' => null,
        'coefficient' => null
    ),
    'Bien' => array(
        'idBien' => '21',
        'designBien' => 'appartement à louer',
        'aPropos' => ' garnd appartement',
        'capaciteAccueil' => '5',
        'nbSalleBain' => '1',
        'nbChambre' => '4',
        'nbLits' => '5',
        'description' => 'garnd appartement',
        'adresse' => 'rue syrie',
        'immeuble' => 'zitouna',
        'affichable' => false,
        'affichablePageAccueil' => false,
        'idtypelogement' => '1',
        'idVille' => '2',
        'idPays' => '0',
        'idTypeBien' => '2',
        'posLat' => '0',
        'posLong' => '0'
        )
         )
            )

       array(
       (int) 0 => array(
    'Reservation' => array(
        'idReser' => '2',
        'dateReserDu' => '2016-04-07',
        'dateReserAu' => '2016-04-20',
        'montantAPaye' => '500',
        'etatReservation' => 'attente',
        'iddev' => '0',
        'idBien' => '22',
        'id' => '24'
    ),
    'Personne' => array(
        'login' => '*****',
        'id' => '24',
        'designation' => 'client',
        'nom' => 'mohamed',
        'prenom' => 'jmaa',
        'dateNaiss' => '1991-07-22',
        'adresse' => 'rue paris',
        'telFixe' => '26119945',
        'telMobile1' => '95632114',
        'telMobile2' => '98745213',
        'email' => 'wahibaml@gmail.com',
        'mdp' => '26111991',
        'lienPhotoPersonnel' => 'sou.jpg',
        'idVille' => '14'
    ),
    'Device' => array(
        'iddev' => null,
        'nomdev' => null,
        'logodev' => null,
        'coefficient' => null
    ),
    'Bien' => array(
        'idBien' => '22',
        'designBien' => 'appartement',
        'aPropos' => 'grand appartement',
        'capaciteAccueil' => '2',
        'nbSalleBain' => '1',
        'nbChambre' => '2',
        'nbLits' => '2',
        'description' => 'grand appartement',
        'adresse' => 'ruen marsa',
        'immeuble' => '',
        'affichable' => false,
        'affichablePageAccueil' => false,
        'idtypelogement' => '1',
        'idVille' => '1',
        'idPays' => '1',
        'idTypeBien' => '1',
        'posLat' => '0',
        'posLong' => '0'
         )
           )
            )

but in the table it show me just 1 line the table Plz what can i do and what is it the mistake ?

来源:https://stackoverflow.com/questions/36830885/cakephp-foreach-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!