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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:08:59+00:00 2026-06-16T03:08:59+00:00

i want to make query like this with cakephp: WHERE text LIKE ‘%keyword%’ AND

  • 0

i want to make query like this with cakephp:

WHERE text LIKE '%keyword%' 
AND 
(
    (text LIKE '%something%') 
    OR (text LIKE '%something%') 
    OR (...)
) 
AND 
(
    (text LIKE '%other%') 
    OR (text LIKE '%other%') 
    OR (...)
) 
NOT 
(
    (text LIKE '%dont include%') 
    OR (text LIKE '%dont include%') 
    OR (...)
)

this is my code for $conditions:

$conditions = array
(
    'Tweet.text LIKE' => '%keyword%',
    'AND' => array(
        array(
            'OR' => array(
                // topic
                array('Tweet.text LIKE' => '%something%'),
                array('Tweet.text LIKE' => '%something%')
            )
        ),
        array(
            'OR' => array(
                // sentiment
                array('Tweet.text LIKE' => '%other%'),
                array('Tweet.text LIKE' => '%other%')
            )
        )
    ),
    'NOT' => array(
        array('Tweet.text LIKE' => '%dont include%'),
        array('Tweet.text LIKE' => '%dont include%')
    )
);

i am displaying the result with Debugger::dump() method, and the result is just using the last ‘OR’ condition, not both ‘OR’ conditions:

array(
    'Tweet.text LIKE' => '%keyword%',
    'OR' => array(
        (int) 0 => array(
            'Tweet.text LIKE' => '%other%'
        ),
        (int) 1 => array(
            'Tweet.text LIKE' => '%other%'
        )
    ),
    'NOT' => array(
        (int) 0 => array(
            'Tweet.text LIKE' => '%dont include%'
        ),
        (int) 1 => array(
            'Tweet.text LIKE' => '%dont include%'
        )
    )
)

My question is, how do I make a query such that use both ‘OR’ condition?

Pls reply as soon as possible.. Thanks in advance 🙂

  • 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-16T03:09:00+00:00Added an answer on June 16, 2026 at 3:09 am

    Try the following:

    $conditions = array(
        'Tweet.text LIKE' => '%aa%',  //implied and
        array( //implied and
            'or' => array(
                array('Tweet.text LIKE' => '%11%'),
                array('Tweet.text LIKE' => '%22%'),
                array('Tweet.text LIKE' => '%33%'),
                ...
            )   
        ),
        array( //implied and
            'or' => array(
                array('Tweet.text LIKE' => '%123%'),
                array('Tweet.text LIKE' => '%456%'),
                array('Tweet.text LIKE' => '%789%'),
                ...
            )   
        )
        'not' => array(
            'or' => array(
                array('Tweet.text LIKE' => '%x%'),
                array('Tweet.text LIKE' => '%y%'),
                array('Tweet.text LIKE' => '%z%'),
                ...
            )   
        )
    )
    

    would be

    text LIKE aa 
        AND ( either 11, 22, 33 ) 
        AND (either 123, 456, 789) 
        BUT NOT (x || y || z)`
    

    Any array that does not specify or, and or not is and. No need to specify it manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make this kind of query: create procedure something @name varchar(13) as
I'm trying to make a query that would do something like this... id |
I want to do something like this in my query: $query = $mysqldb->make_query(SELECT *
Got question. If i make query to server i use something like this: mysql_query(select
i want to make a query like this createQuery(FROM Grouping g WHERE :user IN
I will make this quick and simple I have a query and I want
I want to make this query on Symfony/Propel SELECT folders.NAME, COUNT(documents.NAME), COUNT(files.idfiles), SUM(files.size) FROM
I want to make a JPQL query with a collection of non entities. This
I want to make a query to list cats that took longer than average
I am using mssql and I want to make a query that returns a

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.