jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

serialize/sleep/store problem I guess #87

Closed glamorous closed 14 years ago

glamorous commented 14 years ago

Hi,

I'm having some problems with this lines of code. In my controlller:

$events = Jelly::select('event')->future()->execute();
$events_array = array();
foreach($events as $event)
{
    $events_array[strftime('%B',$event->stardate)][] = $event;
}

In my view I do a foreach for the $events_array and then for every array inside it do another foreach. I expected that that return every Model but instead I recieve the same Model, every time... If I do an "echo" before storing it to an array, it's have the correct value. When I "echo" the array in this foreach in my Controller, it have 2 values (the same model...)

Don't know how to debug this and if it's a Jelly thing but I suppose it.

jonathangeiger commented 14 years ago

Closed by 804dd509cdfaf2b191b4aeae6bc8d4c2930b49ac. Thanks glamorous!

glamorous commented 14 years ago

Jonathan, did you test this? Seems like I still don't get my startdate... :(

jonathangeiger commented 14 years ago

It is tested here.

Can you give me a bit more information? I'm not entirely sure what you mean by your comment.

glamorous commented 14 years ago

My mistake: instead of $event->startdate i've wrote $event->stardate

Should that not be changed and give an error? Because I thought you can't call anything else that isn't in the meta-fields? Finding mistakes in programmers own code should be a lot easier :)

jerfowler commented 14 years ago

Personally, I feel it should be the responsibility of the coder to clone his own models. Otherwise your just instantiating objects, duplicating array values, eating memory and wasting processor cycles every time you iterate through a collection.