Hi!
This is probably a stupid question, but I'm stuck:
I have the models "profiles" and "events". Both have a HABTM
association to each other. Now I want to find all Events that belong
to a single profile.
I tried (in my profiles controller, thats why I use $this->Profile-
>Event->...):
$this->Profile->Event->findAll('Event.profile_id=12',null,'Event.date
ASC',null,null,3);
$this->Profile->Event-
>findAll('EventsProfile.profile_id=12',null,'Event.date ASC',null,null,
3);
$this->Profile->Event->findAll('Profile.id=12',null,'Event.date
ASC',null,null,3);
I also tried with var uses=array('Event') and then:
$this->Event->findAll('Event.profile_id=12',null,'Event.date
ASC',null,null,3);
...
But I always get the sql error message that the "profile id" colum is
unknown.
The associations should be ok, because my whole application works fine
with these associations.
Or ist it just impossible to do what I want to with cake?
I need it that way because actually I want the following condition in
the findAll():
'Event.date > NOW() AND (Event.type!=\'personal\' OR (Event.type=
\'personal\' AND Profile.id=12)'
to select all non-personal events plus the personal events of the
specified profile id.
The models:
profile.php
var $hasAndBelongsToMany = array(
'Event' =>
array('className' => 'Event',
'joinTable' => 'events_profiles',
'foreignKey' => 'profile_id',
'associationForeignKey' => 'event_id',
'conditions' => '',
'order' => 'Event.date ASC',
'limit' => '',
'uniq' => true,
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
event.php
var $hasAndBelongsToMany = array(
'Profile' =>
array('className' => 'Profile',
'joinTable' => 'events_profiles',
'foreignKey' => 'event_id',
'associationForeignKey' => 'profile_id',
'conditions' => '',
'order' => '',
'limit' => '',
'uniq' => true,
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
Any ideas?
Thanks
el_baker
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---