I think this can resolve your problem but isn't the better solution.

        $categorieProducts = $this->CategorieProducts->find('list', 'fields'
=> array('category_id'), array('conditions' =>
array('CategorieProducts.category_id' => $category_id)));
        $products = $this->Product->find('all', array('conditions' =>
array('NOT' => array('Product.id' =>
$categorieProducts['CategorieProducts'])), 'order' => 'Product.id
AS'));
        $this->paginate($products);

Kind regards.

On Dec 17, 5:32 am, ionatan <[email protected]> wrote:
> 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

Reply via email to