I had a similar problem and first off I did a query to get record id's and
pass that as NOT IN => $my_ids then was turned to sub querys which ran that
same query inside the paginator query. Both returned the same results yet
the subquery was faster and cleaner.

http://book.cakephp.org/view/74/Complex-Find-Conditions near the bottom
there.

Dave


-----Original Message-----
From: ionatan [mailto:[email protected]] 
Sent: December-17-10 5:02 AM
To: CakePHP
Subject: Paginator with "NOT IN"

Hello, I have a table products, a table categories and a table
categories_products with category_id, product_id as foreign keys.

I need to make a paginator to display all products that not belong to
the selected category.

Something like this:
SELECT * FROM products WHERE id NOT IN (SELECT product_id FROM
categories_products WHERE category_id='".$category_id."') ORDER BY
products.id ASC

Or maybe with a JOIN?!

How I can do this with Cake? And in which controller?
products_controller, or categories_products_controller ?

Thank you.

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to