Wednesday, August 24, 2011

Re: Subquery or something else?

I agree that there are better single query methods in pure SQL, but my recommendation keeps it in a Cake stylee (rather than using $model->query). I'd be happy to be put right, but even if you did it using joins in a Cake find, I think it'd still execute two queries.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 23 Aug 2011, at 19:25, Robert Maiolo wrote:

I'd try an outer join


On Tue, Aug 23, 2011 at 11:23 AM, euromark <dereuromark@googlemail.com> wrote:
although this will get quite slow with more and more ids and might
consume a lot of memory some day
depending on the size a subquery might some day be more suitable. but
until then this 2-query will work fine.


On 23 Aug., 13:44, Dwayne Hanekamp <dwaynehanek...@gmail.com> wrote:
> That worked, awesome!
>
> Thanks so much Jeremy!
>
> Dwayne
>
> On 23 aug, 12:48, Jeremy Burns | Class Outfit
>
>
>
>
>
>
>
> <jeremybu...@classoutfit.com> wrote:
> > Do a find to get all the ids of the badges in the users_badges table. Then do $this->Badge->find('all', array('conditions' => array('NOT' array('Badge.id' => $badgeIds))));
>
> > Seehttp://book.cakephp.org/view/1030/Complex-Find-Conditionsandsearch for 'NOT IN' on the page.
>
> > Jeremy Burns
> > Class Outfit
>
> >http://www.classoutfit.com
>
> > On 23 Aug 2011, at 11:43, Dwayne Hanekamp wrote:
>
> > > Hello everyone,
> > > I've been trying to work this out for the last couple of hours but it
> > > isn't working.
> > > I'm building an achievement system. So i have two tables:
>
> > > Users_Badges and Badges (and ofc much more but they don't matter)
>
> > > What i want is to make a find condition which only selects the badges
> > > that don't
> > > exist in the Users_Badges table.
>
> > > I hope you all can help me.
>
> > > Thanks in advance,
>
> > > Dwayne
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: