Read the article on Containable, implemented it and
DAMN!
works like a charm!

Meanwhile, I've also added a slight modification to the table, so I can
make a hasMany relation.

Now, all I need is to learn to use Class::Set, to modify the array I have.

Thanks for help so far! *thumbs up*

>
> 2009/4/23 Faza <[email protected]>:
>>
>> Hi all,
>>
>> more newbie questions on the way.
>>
>> I have few models related (mostly $belongsTo), and one of them requires
>> a level 3 recursion, which is not-a-very-good practice. Especially that
>> enabling lvl 3 recursion gathers much more data from the model than I
>> really need.
>>
>> Therefore I thought that I could extend the model using some function to
>> get the data I need, and then merge it with the result of findAll.
>>
>> The problem is, I don't have a clue where to start.
>
> Have you had a look at ContainableBehavior? I'd bet using that would
> be a lot easier.
>
>>
>> 1st of all, how to make Cake run my function each iteration of the
>> "foreach $results as $result"? I need this, because - obviously - I have
>> to pass the id of each row to the function.
>
> Not necessarily. You could extract the IDs with one call using Set
> class and then make one query using the resulting array.
>
> $foreign_keys = Set::extract($results, '{n}.SomeModel.id');
>
> I still think you should be using contain, though, and avoiding the
> need for any of this.
>>
>> ...
>>
>> What I want to get, is that result of findAll will be expanded with the
>> above fields.
>>
>> Plz bear with my newbieness and ask away if there's something I didn't
>> describe good enough to be understood.
>
> You haven't given any indication of the *other* data, the initial find
> you're making, nor how all of these models are associated. There's not
> much to go on.
>
> >
>


-- 
Jacek


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

Reply via email to