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 8062261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:36:29+00:00 2026-06-05T10:36:29+00:00

Cake PHP complex find ‘OR’ opertor is not working properly with null… $conditions =

  • 0

Cake PHP complex find ‘OR’ opertor is not working properly with null…

$conditions = array(
    'Person.id' => array(2, 4, 1, 23, 45, 11),
    'OR' => array(
    array(
        array('NOT' => array('Person.image' => null)),
        array('NOT' => array('Person.image' => '')),
    ),
    array(
        array('NOT' => array('Person.photos' => null)),
        array('NOT' => array('Person.photos' => '')),
    )
    )
);

The corresponding cake sql dump output query as below

SELECT `Person`.`id`, `Person`.`created`, `Person`.`modified` 
FROM `people` AS `Person` WHERE `Person`.`id` IN (2, 4, 1, 23, 45, 11)  AND 
((((NOT (`Person`.`image` IS NULL)) AND (NOT (`Person`.`image` = NULL))))   OR 
(((NOT (`Person`.`photos` IS NULL)) AND (NOT (`Person`.`photos` = ''))))) 
ORDER BY FIELD(`Person`.`id`, 2, 4, 1, 23, 45, 11) ASC LIMIT 3

In cake condition array, I have given Person.image is not null or '', but corresponding cake sql outputs as (NOT (Person.image IS NULL)) AND (NOT (Person.image = NULL)) where it should be like (NOT (Person.image IS NULL)) AND (NOT (Person.image = '')) .

Here Person.image both are compared with NULL itself(IS NULL and = NULL), where Person.image = NULL want to compared with empty string like Person.image = ”.

Here 'Person.image' is 'INT' and 'Person.photos' is 'VARCHAR' of type, but it is difficult to change type from current stage.

How it can be corrected ?

  • 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-05T10:36:31+00:00Added an answer on June 5, 2026 at 10:36 am

    You are not forced to use an associative array to define conditions. You can define it like so:

    $conditions = array(
        'Person.id' => array(2, 4, 1, 23, 45, 11),
        'OR' => array(
        array(
            array('NOT' => array('Person.image' => null)),
            array('NOT' => array('Person.image = "" ')),
        ),
        array(
            array('NOT' => array('Person.photos' => null)),
            array('NOT' => array('Person.photos = "" ')),
        )
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In cake php how to avoid one or more elements in option array of
i want to convert zend php to cake php but not finding correct book
Cake Php Read function to retrieve result as simple array $result = $this->Model->read('id, name,
The cake php validation 'isUnique' gives error on edit var $validate = array( 'name'
I am uploading a file in cake php. <?php echo $form->create(Video,array('action'=>'add','name'=>'thisform','enctype'=>'multipart/formdata','onsubmit'=>'javascript: return validate();')); echo
I am working through the Cake PHP 1.3 Application Development Cookbook, CH. 1 --
At work, I am working with this old legacy code modified Cake-PHP code that
why cake PHP framework not recognize true syntax in this example User has Many
In cake php is how we can get order of query result according to
I have go TCPDF setup in my cake php install and am now trying

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.