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?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---