Re: Containable not containing
Cricket, you are absolutely brilliant! Sure enough, no task with id=2. How I got an assignment in there without a valid task, I dunno, but that's a problem for another day... Thanks! Brenda 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Containable not containing
Are you certain that you have a Task with ID = 2? Try setting debug to 2 and running the SQL directly in a terminal (or web interface, etc.) Also, I recommend that you list the fields in a separate array, if only for clarity. 'contain' => array( 'Event' => array( 'fields' => array('id', 'event', 'project_id', 'event_date'), 'Project' => array( 'project', 'ProjectStatus.project_status' ) ) ) On Mar 6, 1:56 pm, Brenda wrote: > I've been scratching my head for hours and can't figure out why this > doesn't work. Any help would be appreciated. > > Projects hasMany Tasks > Projects hasMany Events > > Projects belongsTo ProjectStatus > > Tasks hasMany TaskVendors > Events hasMany EventVendors > > TaskVendors belongsTo Vendors > EventVendors belongsTo Vendors > > Tasks belongsTo TaskStatus > Events belongsTo EventStatus > > I have two finds happening in the Vendor model: > > $events = $this->EventVendor->find('all', array( > 'conditions' => array( > 'EventVendor.vendor_id' => $vendorId > ), > 'contain' => array( > 'Event' => array( > 'id', 'event', 'project_id', 'event_date', > 'Project' => array( > 'project', 'ProjectStatus.project_status' > ) > ) > ) > )); > > and > > $tasks = $this->TaskVendor->find('all', array( > 'conditions' => array( > 'TaskVendor.vendor_id' => $vendorId > ), > 'contain' => array( > 'Task' => array( > 'id', 'task', 'project_id', 'due_date', > 'TaskStatus' => array( > 'task_status' > ), > 'Project' => array( > 'project', 'ProjectStatus.project_status' > ) > ) > ) > )); > > The events one is working properly and returns something like > > [0] => Array > ( > [EventVendor] => Array > ( > [id] => 5 > [event_id] => 11 > [vendor_id] => 1 > [label] => mover > [notes] => > ) > > [Event] => Array > ( > [id] => 11 > [event] => Pack Day > [project_id] => 11 > [event_date] => Feb 25, 2010 > [Project] => Array > ( > [project] => OakCrest-123 > [project_status_id] => 1 > [ProjectStatus] => Array > ( > [project_status] => Active > ) > > ) > > ) > > ) > > [1] => Array > ( > [EventVendor] => Array > ( > [id] => 7 > [event_id] => 12 > [vendor_id] => 1 > [label] => mover > [notes] => > ) > > [Event] => Array > ( > [id] => 12 > [event] => Move (full day) > [project_id] => 11 > [event_date] => Feb 26, 2010 > [Project] => Array > ( > [project] => OakCrest-123 > [project_status_id] => 1 > [ProjectStatus] => Array > ( > [project_status] => Active > ) > > ) > > ) > > ) > > but the tasks one isn't returning the deeper associations: > > [0] => Array > ( > [TaskVendor] => Array > ( > [id] => 10 > [task_id] => 2 > [vendor_id] => 1 > [label] => Mover > [notes] => > ) > > [Task] => Array > ( > [id] => > [task] => > [project_id] => > [due_date] => > ) > > ) > > [1] => Array > ( > [TaskVendor] => Array > ( > [id] => 12 > [task_id] => 1 > [vendor_id] => 1 > [label] => mover > [notes] => > ) > > [Task] => Array > ( > [id] => >
Re: Containable not containing
Hi Michael, Thanks for looking at this. I've tried switching the order, to tasks goes before events, but still no joy. I've even taken out all the deeper contained data, and it still won't find anything. Maybe something is going wrong with 'recursive', but I thought that wasn't used with 'contain.' BTW, I forgot to mention that tasks actsAs 'tree' as well as 'containable'. 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Containable not containing
Hi Brenda, I just experienced a similar problem, and it seems that the first find influences the second, if the containment is too deep. Looks like a bug for me, but I am not sure and I also don't use the latest CakePHP version. As workaround in your case, it might help to change 'ProjectStatus.project_status' to 'ProjectStatus' and just accept the additional data beside 'project_status'. Hope this helps, Michael On Mar 6, 7:56 pm, Brenda wrote: > I've been scratching my head for hours and can't figure out why this > doesn't work. Any help would be appreciated. > > Projects hasMany Tasks > Projects hasMany Events > > Projects belongsTo ProjectStatus > > Tasks hasMany TaskVendors > Events hasMany EventVendors > > TaskVendors belongsTo Vendors > EventVendors belongsTo Vendors > > Tasks belongsTo TaskStatus > Events belongsTo EventStatus > > I have two finds happening in the Vendor model: > > $events = $this->EventVendor->find('all', array( > 'conditions' => array( > 'EventVendor.vendor_id' => $vendorId > ), > 'contain' => array( > 'Event' => array( > 'id', 'event', 'project_id', 'event_date', > 'Project' => array( > 'project', 'ProjectStatus.project_status' > ) > ) > ) > )); > > and > > $tasks = $this->TaskVendor->find('all', array( > 'conditions' => array( > 'TaskVendor.vendor_id' => $vendorId > ), > 'contain' => array( > 'Task' => array( > 'id', 'task', 'project_id', 'due_date', > 'TaskStatus' => array( > 'task_status' > ), > 'Project' => array( > 'project', 'ProjectStatus.project_status' > ) > ) > ) > )); > > The events one is working properly and returns something like > > [0] => Array > ( > [EventVendor] => Array > ( > [id] => 5 > [event_id] => 11 > [vendor_id] => 1 > [label] => mover > [notes] => > ) > > [Event] => Array > ( > [id] => 11 > [event] => Pack Day > [project_id] => 11 > [event_date] => Feb 25, 2010 > [Project] => Array > ( > [project] => OakCrest-123 > [project_status_id] => 1 > [ProjectStatus] => Array > ( > [project_status] => Active > ) > > ) > > ) > > ) > > [1] => Array > ( > [EventVendor] => Array > ( > [id] => 7 > [event_id] => 12 > [vendor_id] => 1 > [label] => mover > [notes] => > ) > > [Event] => Array > ( > [id] => 12 > [event] => Move (full day) > [project_id] => 11 > [event_date] => Feb 26, 2010 > [Project] => Array > ( > [project] => OakCrest-123 > [project_status_id] => 1 > [ProjectStatus] => Array > ( > [project_status] => Active > ) > > ) > > ) > > ) > > but the tasks one isn't returning the deeper associations: > > [0] => Array > ( > [TaskVendor] => Array > ( > [id] => 10 > [task_id] => 2 > [vendor_id] => 1 > [label] => Mover > [notes] => > ) > > [Task] => Array > ( > [id] => > [task] => > [project_id] => > [due_date] => > ) > > ) > > [1] => Array > ( > [TaskVendor] => Array > ( > [id] => 12 > [task_id] => 1 > [vendor_id] => 1 > [label] => mover > [notes] => > ) > > [Task] => Array > ( > [id] => > [task] => > [project_id] => >
Containable not containing
I've been scratching my head for hours and can't figure out why this doesn't work. Any help would be appreciated. Projects hasMany Tasks Projects hasMany Events Projects belongsTo ProjectStatus Tasks hasMany TaskVendors Events hasMany EventVendors TaskVendors belongsTo Vendors EventVendors belongsTo Vendors Tasks belongsTo TaskStatus Events belongsTo EventStatus I have two finds happening in the Vendor model: $events = $this->EventVendor->find('all', array( 'conditions' => array( 'EventVendor.vendor_id' => $vendorId ), 'contain' => array( 'Event' => array( 'id', 'event', 'project_id', 'event_date', 'Project' => array( 'project', 'ProjectStatus.project_status' ) ) ) )); and $tasks = $this->TaskVendor->find('all', array( 'conditions' => array( 'TaskVendor.vendor_id' => $vendorId ), 'contain' => array( 'Task' => array( 'id', 'task', 'project_id', 'due_date', 'TaskStatus' => array( 'task_status' ), 'Project' => array( 'project', 'ProjectStatus.project_status' ) ) ) )); The events one is working properly and returns something like [0] => Array ( [EventVendor] => Array ( [id] => 5 [event_id] => 11 [vendor_id] => 1 [label] => mover [notes] => ) [Event] => Array ( [id] => 11 [event] => Pack Day [project_id] => 11 [event_date] => Feb 25, 2010 [Project] => Array ( [project] => OakCrest-123 [project_status_id] => 1 [ProjectStatus] => Array ( [project_status] => Active ) ) ) ) [1] => Array ( [EventVendor] => Array ( [id] => 7 [event_id] => 12 [vendor_id] => 1 [label] => mover [notes] => ) [Event] => Array ( [id] => 12 [event] => Move (full day) [project_id] => 11 [event_date] => Feb 26, 2010 [Project] => Array ( [project] => OakCrest-123 [project_status_id] => 1 [ProjectStatus] => Array ( [project_status] => Active ) ) ) ) but the tasks one isn't returning the deeper associations: [0] => Array ( [TaskVendor] => Array ( [id] => 10 [task_id] => 2 [vendor_id] => 1 [label] => Mover [notes] => ) [Task] => Array ( [id] => [task] => [project_id] => [due_date] => ) ) [1] => Array ( [TaskVendor] => Array ( [id] => 12 [task_id] => 1 [vendor_id] => 1 [label] => mover [notes] => ) [Task] => Array ( [id] => [task] => [project_id] => [due_date] => ) ) Any clue why, or where I should look? Thank you very much. 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en