Thursday, November 27, 2008

Re: Multiple table access from within a model

You need to set recursive to tell Cake to fetch the related data.

See: http://book.cakephp.org/view/439/recursive or
http://api.cakephp.org/class_model.html#e60758f27fa8486a063b8cc424bad741

On Nov 25, 3:48 pm, Jason <Jason.Ka...@gmail.com> wrote:
> I have the following tables,
>
> events
> +-id
> +-offering_id
> ...
>
> offerings
> +-id
> +-program_id
> +-start_date
> ...
>
> programs
> +-id
> +-name
> ...
>
> One program could have many offerings, but each offering is tied to
> one program.  I have the $belongsTo and $hasMany set up via Bake.  I
> would like to regularly be able to grab the associated row from
> `programs` and use the afterFind function to dynamically create the
> offering name (which will be a concatenation of the program name and
> the offering start date.)  However, only sometimes does the associated
> Program appear in the results.  Specifically, when accessing the
> offerings_controller, associated events and programs appear in the
> results.  But when I use the events_controller, Program is not in the
> results array.  I have defined $uses = Array( 'Event', 'Offering',
> 'Program' ) in the events_controller, but still no dice.  Is there a
> way to tell a model that I need it to pull the associated Program
> record EVERY TIME?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: