Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:21:21+00:00 2026-06-15T23:21:21+00:00

$conditions = Array ( [table] => products_pages [alias] => ProductsPage [type] => inner [foreignKey]

  • 0
$conditions = Array
(
  [table] => products_pages
  [alias] => ProductsPage
  [type] => inner
  [foreignKey] => 
  [conditions] => Array
  (
   [0] => ProductsPage.product_id = Product.id
  )
)

I’m trying to set up NOT EXISTS conditions, like the following SQL statement:

SELECT * FROM products_pages,products 
WHERE NOT EXISTS (SELECT id 
                  from products_pages 
                  where products_pages.product_id = products.id)

So basically select any product that doesn’t exist in the products_pages table.

What is the proper way to format that SQL statement for CakePHP and replace it here:

[conditions] => Array
(
[0] => (What’s the proper way to insert above SQL here?
)

Would really appreciate your help guys, I’ve been trying to figure this out for about 5 hours with no luck. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:21:23+00:00Added an answer on June 15, 2026 at 11:21 pm

    You can always use query if you don’t find the way to do it with CakePHP:
    http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query

    In this case security wouldn’t be compromised as you are not using any input.

    Anyway, something simple would be just to do it in more than one step:

    //selecting the products in the productcs_pages table
    $productsWithPages = /* query to get them*/
    
    //getting an array of IDs
    $productsWidthPagesIds = Hash::extract($productsWithPages, '{n}.Product.id');
    
    //doing the NOT IN to select products without pages
    $productsWithoutPages= $this->Product->find('all', 
            array('conditions' => 
                 array( 'NOT' => array('Product.id' => $productsWidthPagesIds )
            )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$this->Release->recursive = 0; $this->paginate['Release']['joins'] = array( array( 'table' => ' game_potential_amazon_matches', 'alias' => 'PotentialAmazonMatch',
I have this in my table model called Table $test = $this->find('first', array( 'conditions'
This is my join query code: $options['joins'] = array( array('table' => 'employees', 'alias' =>
In my project ` $cid = $this->Surgical->find('first',array('conditions' => array('to_char(dt_surgery , \'DD-MM-YYYY\' )' =>'to_char(now() ,\'DD-MM-YYYY\')')));
I have the code: $getCookieData = $this->Cookie->read('data'); $getUser = $this->User->find('first', array('conditions' => array('User.username' =>
Conditions: Windows 98 SE WMI not available I have code that looks like this,
How do I set conditions to affect all images within my webpage (via CSS)
I have a site develop in cakephp 2.0. I have a table Product related
Do you see any syntax errors here? 'Coupon'=>array( 'fields'=>array( 'promo_code','desc' ), 'conditions'=>array( 'OR'=>array( 'expires'
I'm trying to join a Users table to my curent hasMany Through table which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.