Re: Subquery or something else?

2011-08-24 Thread Jeremy Burns | Class Outfit
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 dereurom...@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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-24 Thread Jens Dittrich
There is a cake way for creating subqueries!

See: http://book.cakephp.org/view/1030/Complex-Find-Conditions and scroll 
down to the section Sub-queries.

There is an example how to build subqueries the cake way and get efficient 
calls to the database.
I would suggest that you are trying to hit the database as little as 
possible to avoid upcoming bottlenecks.

regards,
Jens

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Subquery or something else?

2011-08-23 Thread Dwayne Hanekamp
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 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-23 Thread Jeremy Burns | Class Outfit
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;

See http://book.cakephp.org/view/1030/Complex-Find-Conditions and search 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 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-23 Thread Dwayne Hanekamp
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-Conditionsand search 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.organd help 
  others with their CakePHP related questions.

  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

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-23 Thread euromark
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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-23 Thread Robert Maiolo
I'd try an outer join


On Tue, Aug 23, 2011 at 11:23 AM, euromark dereurom...@googlemail.comwrote:

 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-Conditionsandsearchfor 
   '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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php