I don't know how your models are linked together but if "recursive" doesn't
get you all the data you need, "containable" will do the trick.

On Thu, Sep 23, 2010 at 2:09 PM, Chris <[email protected]> wrote:

> Hi there!
>
>
> I'm pretty new to CakePHP and I recently met a problem that I actually
> can not resolve by myself, so I would like some help understanding the
> source of the problem.
>
> I have an events table that contains, with others things, a
> 'location_id' field.
> I have a locations table containing a 'country_id' field.
> And I have a countries table that contains some data related to
> specific countries.
>
> Now, what I would like to get, is a page containing data for a
> specific event: it works. But my array looks like this:
>
>
> Array
> (
>    [Event] => Array
>        (
>            [id] => 1
>            [created] => 2010-09-22 23:57:39
>            [modified] => 2010-09-22 23:57:39
>            [name] => Test event
>            [start_date] => 2010-09-23 20:00:00
>            [end_date] => 2010-09-24 03:00:00
>            [location_id] => 1
>        )
>
>    [Location] => Array
>        (
>            [id] => 1
>            [name] => My home
>            [street] => Here street
>            [house_number] => 128
>            [zip_code] => 7000
>            [city] => Mons
>            [country_id] => 1
>        )
> )
>
> I'd like to append a branch related to the country. I thought it could
> be "automagically" did, but I probably made a mistake. For now, in my
> events_controller file, I do this to get the data related to the
> location's country:
>
>
>                        $data['Country'] =
> ClassRegistry::init('Countries')->find(
>                                'all', array(
>                                'conditions' => 'Countries.id =
> '.$data['Location']['country_id']
>                                )
>                        );
>                        $data['Country'] = $data['Country'][0]['Countries'];
>
>                        $this->set('data', $data);
>
> But It looks crap and I suppose that a "clean" way to to this exists.
> But I really do not know what to do with that.
>
>
> Please someone to help me? (-:
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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