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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:48:15+00:00 2026-05-26T03:48:15+00:00

I am trying to find countries with conditions set as a variable, it looks

  • 0

I am trying to find countries with conditions set as a variable, it looks like this:

$conditions = '1,2,3';
$this->set('options',
    $this->Agency->Country->find('list',
        array(
            'conditions' => array(
                'Country.zone_id' => array($conditions)
             ) 
        )
    )
);

This should result in finding all the countries with zone_id = 1 or 2 or 3.

But in this case only the first value in the $conditions is taken to an account, so in this case it works like Country.zone_id' => array(1). It returns only the countries with zone_id = 1. Why all the other are skipped?

  • 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-05-26T03:48:15+00:00Added an answer on May 26, 2026 at 3:48 am

    I think the value is converted to an int which means the rest after “1” is ignored. If an array is supplied then it behaves like an IN clause in SQL with each array entry as a value to be checked against.

    So if you have to use a string with each ID separated by a comma then try the following:

    'conditions' => array(
        'Country.zone_id' => explode(",", $conditions)
    )
    

    Otherwise if you have already an array of numerical ID’s then you can assign it directly:

    'conditions' => array(
        'Country.zone_id' => array(1, 2, 3),
    )     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of countries, html, they have numeric ids and country name:
Trying to find some information on this but am unable to get any results
Hey everyone I've looked for hours trying to find a solution to this, my
trying to find an example of this, it's possible that I am not going
Trying to find the best way to write this SQL statement. I have a
Trying to find out what the (float) in this function means: static float avgEndpoints
i trying find something like jsfiddle.net resizable layout, but lightweight. i found http://www.jquery-css.com/download-css-jquery-templates http://layout.jquery-dev.net/
I'm trying find a way to implement dashed list (–) in CKEDITOR. Standart html
I am learning regular expressions and I am trying find this string day1otlk_XXXX.gif where
Trying to find some simple SQL Server PIVOT examples. Most of the examples that

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.