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 th
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
I'd try an outer join
On Tue, Aug 23, 2011 at 11:23 AM, euromark 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.
>
>
>
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 wrote:
> That worked, awesome!
>
> Thanks so much J
That worked, awesome!
Thanks so much Jeremy!
Dwayne
On 23 aug, 12:48, Jeremy Burns | Class Outfit
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;
>
> Seeht
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 Out