sweet, THANK YOU! :)
On Feb 17, 6:59 pm, "Grant Cox" <[EMAIL PROTECTED]> wrote:
> Change your Intinerary's Event association to
>
> var $hasMany = array('Event' => array('className' => 'Event') );
>
> in your itineraries/view action, have something like
>
> function view($id) {
> $this->Itinerary->recursive = 1;
> $itinerary = $this->Itinerary->read(null, $id);
> $this->set('itinerary', $itinerary);
>
> }
>
> and in your view, do a print_r($itinerary) to see how the associations
> come through in your data array.
>
> Or, just bake the whole lot - it can make all your models, controllers
> and views, just make sure you tell it the right associations.
>
> On Feb 17, 11:26 am, "strykstaguy" <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have tried to read the manual and look at examples but I am having a
> > hard time with associations.
>
> > For one, I have a three tables. Trips, Itineraries, Events
>
> > Each has one Itinerary, Each Itinerary has many events.
>
> > What i really want right now is to connect my Itineraries to Events,
> > Currently when i display my itineraries it repeats them 6 times
> > instead of twice (the number of itineraries i have right now). I want
> > once i select an itinerary is to view the events that match that
> > itinerary.
>
> > itinerary.php
> > ***********************
> > <?
>
> > class Itinerary extends AppModel
> > {
> > Var $name = 'Itinerary';
> > var $hasOne = array('Event' =>
> > array('className' => 'Event',
> > 'conditions' => '',
> > 'order' => '',
> > 'dependent' => false,
> > 'foreignKey' => 'itinerary_id'
> > )
> > );
> > var $validate = array(
>
> > 'title' => VALID_NOT_EMPTY,
> > 'creator' => VALID_NOT_EMPTY,
> > 'when' => VALID_NOT_EMPTY
>
> > );
>
> > }
>
> > ?>
> > ***********************************************************
> > events.php
>
> > **********************************************************
> > <?
>
> > class Event extends AppModel
> > {
> > Var $name = 'Event';
> > var $belongsTo = array('Itinerary' =>
> > array('className' => 'Itinerary',
> > 'conditions' => '',
> > 'order' => '',
> > 'foreignKey' => 'itinerary_id'
> > )
> > );
> > var $validate = array(
>
> > 'what' => VALID_NOT_EMPTY,
> > 'where' => VALID_NOT_EMPTY,
> > 'andwhen' => VALID_NOT_EMPTY
>
> > );
>
> > }
>
> > ?>
>
> > *****************************************************************
>
> > What it all comes down to is I know how to connect them with HasMany
> > and BelongsTo but i don't know how to actually display the events info
> > in the 'View' of my itineraries.
>
> > Any Help?- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---