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 <m...@jakobjp.net> wrote:
>
> 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 = false) {
>    if ($id) $this->load($id);
>    return $this;
>  }
>  function load($id) {
>    ... do something to load apple with `id` = $id from db ...
>  }
>  function isRed() {
>    if ($this->color == 'red') return true;
>    else return false;
>  }
> }
>
>
> In my code I would then often work like this:
>
> $apple = new Apple(123);
> if ($apple->isRed()) echo 'Apple is red";
> else echo 'Apple is not red';
>
>
> Now my question:
> Where would a function like isRed() be located in the the CakePHP-way?
>
> Since in Cake I don't have an object to call a model's method on, I am
> not sure how to go about this...
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to