Re: Objects vs. arrays

2009-05-25 Thread Sidney
]['red'])) { >     $color = $this->data['Apple']['color']; >   } >   return $colour == 'red'; > > } > > -Mark > > On May 23, 9:59 am, jakobjp wrote: > > > I've read a few discussions about CakePHP returning objects vs.

Re: Objects vs. arrays

2009-05-24 Thread jakobjp
lor = $this->data['Apple']['color']; >   } >   return $colour == 'red'; > > } > > -Mark > > On May 23, 9:59 am, jakobjp wrote: > > > > > I've read a few discussions about CakePHP returning objects vs. > > arrays, a

Re: Objects vs. arrays

2009-05-24 Thread mark_story
isRed method could look like function isRed($color = null) { if (!$color && isset($this->data['Apple']['red'])) { $color = $this->data['Apple']['color']; } return $colour == 'red'; } -Mark On May 23, 9:59 am, jakobjp wrote:

Re: Objects vs. arrays

2009-05-23 Thread DanielMedia
The code above is for a Model but if you want presentational (in the view) code, maybe consider creating an AppleHelper with that type of logic instead. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group.

Re: Objects vs. arrays

2009-05-23 Thread DanielMedia
You could still have the isRed() function in your model. class Apple extends AppModel { function isRed($color = null){ if($color == 'red'){ return true; } return false; } } So If you're working in your controller: $apple = $this->Apple->r

Re: Objects vs. arrays

2009-05-23 Thread brian
For the given example, it looks to me like you'd do this in the view: if ($data['Apple']['color'] == 'red') On Sat, May 23, 2009 at 9:59 AM, jakobjp wrote: > > I've read a few discussions about CakePHP returning objects vs. > arrays, and this i

Objects vs. arrays

2009-05-23 Thread jakobjp
I've read a few discussions about CakePHP returning objects vs. arrays, and this is NOT intended to be such. I just have a question, related to it: I used to have (i.e. "before CakePHP") objects like this: class Apple { var $color; var $sweet; function __construct($id =