Re: Simplify foreach() - unpleasant array

2007-01-10 Thread bernardo
I created an iterator for this. You'll need php5. You can use it like this: $resiter = new modelIterator("Reservation",$reservations); foreach($resiter as $reservation) { echo $reservation['id']; echo $reservation['created']; } The class is very simple: class mo

Re: Simplify foreach() - unpleasant array

2007-01-10 Thread Grant Cox
Except that in this case the array is $reservations[ {n} ]['Reservation'] . You should only have ['Reservation'][ {n} ] when that Reservation model is loaded indirectly through an associated hasMany - ie where Person hasMany Reservation (recursive 1) $people = Person->findAll() gives: $people[

Re: Simplify foreach() - unpleasant array

2007-01-10 Thread RichardAtHome
Grant Cox wrote: > Using $reservation['Reservation']['number']; is correct. This is > because each retrieved row may have associated models - ie > $reservation['Room'] etc. Ah, another chink of sunlight just broke through the clouds :-) I was going to ask this same question myself. My workaro

Re: Simplify foreach() - unpleasant array

2007-01-09 Thread dani
OK, thank you! Then I see the point ... On Jan 10, 12:47 am, "Grant Cox" <[EMAIL PROTECTED]> wrote: > Using $reservation['Reservation']['number']; is correct. This is > because each retrieved row may have associated models - ie > $reservation['Room'] etc. --~--~-~--~~

Re: Simplify foreach() - unpleasant array

2007-01-09 Thread Grant Cox
Using $reservation['Reservation']['number']; is correct. This is because each retrieved row may have associated models - ie $reservation['Room'] etc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" gro

Simplify foreach() - unpleasant array

2007-01-09 Thread dani
Controller: $this->set('reservations',$this->Reservation->findAll()); View: foreach($reservations as $reservation) { echo $reservation['Reservation']['number']; } Can I make this: echo $reservation['number'] - instead? I've tried foreach($reservations['Reservation']) bu