Tuesday, August 23, 2011

Re: Subquery or something else?

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

No comments: