Hi,

After many tries, I finally found the solution myself.
Thanks


On Apr 26, 4:34 pm, Luck <lucio...@gmail.com> wrote:
> Hi,
> I have googled for similar problems and still cannot find a solution
> on how to build a 'NOT EXISTS' query. I'm newbie to CakePHP.
>
> I have two simple models: Question and Answer. Question has a hasMany
> relationship with Answer, as the answers table has a foreign key to
> questions. Very simple.
>
> Problem one is, I want to do a find for those queries with no answers,
> in SQL would be just like this:
>
> SELECT * FROM questions where not exists (select 1 from anwers where
> answers.question_id=questions.question_id);
>
> How do I do this in CakePHP? Is there any way to include other finds
> in the conditions? I mean not only field matches like the
> documentation shows.
>
> The second step is paginate that. How should I alter the current
> pagination? (currently it paginates all the questions)
> $this->set('questions',$this->paginate('Question'));
>
> Thanks
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> athttp://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 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

Reply via email to