Aahhh.. good idea... I'll try that in the morning and see how it works
out...

thanks!

On Sat, Dec 5, 2009 at 2:35 PM, Tonu Tusk <[email protected]> wrote:

> ok - probably not the most efficient, but the following should work if
> your relationships are setup in the models
>
> $submissions = $this->Submission->find('all', array('fields' => array
> ('DISTINCT student_id'), 'recursive' => -1);
> $student_ids =Set::extract($submissions, '/Submission/student_id');
> // this gets an array of student Ids that do have submissions
>
> $contains = array('User' => array('fields' => array('id'))); //
> whatever other fields you want from your User record in here, or just
> leave the fields parameter out to retrieve all User fields
> $conditions = array('NOT' => array('Student.id' => $student_ids));
> $students = $this->Student->find('all', array('conditions' =>
> $conditions, 'contain' => $contains, 'fields' => array('id)));
> // this gets the Student records (trimmed down to just id) whose ids
> are not in the list of student ids with submissions
> // the resulting dataset for each student will also have a User entry
> relating to the related associated User  record.
>
> // change the find call on the Student Model to list if you only want
> ids, or alter the containable parameters if you are working on the
> resulting dataset directly
> // OR use some set::extract functions to tailor the results you need.
>
>
>
> On Dec 4, 5:15 pm, abryant <[email protected]> wrote:
> > You might also try (from the book.cakephp.org page on Containable)
> >
> >         $list = $this->User->find('all', array(
> >           'contain' => array(
> >             'Student' => array(
> >               'Submission.student_id' => null
> >             )
> >           )
> >         ));
> >
> > At least according to the examples in the manual this is an appropriate
> way
> > to filter conditionally on a specific field in a contained relationship
> > --
> > View this message in context:
> http://n2.nabble.com/Containable-query-tp4057992p4113719.html
> > Sent from the CakePHP mailing list archive at Nabble.com.
>
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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 [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

Reply via email to