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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:32:33+00:00 2026-06-10T08:32:33+00:00

I have a long query like this: $a=$this->Signin->find(‘all’, array( ‘fields’=> array( ….. ), ‘conditions’

  • 0

I have a long query like this:

$a=$this->Signin->find('all',
    array(
        'fields'=> array(
            .....
        ),
        'conditions' => array('mytable.user_type ...),
        'order' => ....
        'limit' => ....
));

user_type column can take values of 0 or 1.
I have a function parameter $type, regarding to this parameter, I need to change my SQL query. Regarding to $type I will query for

  • “mytable.user_type”=1,
  • “mytable.user_type”=0,
  • “mytable.user_type”=1 OR “mytable.user_type=0

I don’t want to write same query three times. I want to change only conditions part. Is it possible?

  • 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-10T08:32:34+00:00Added an answer on June 10, 2026 at 8:32 am

    you can define $type as an array and manage the values in $type

    Like for multiple values

    $type = array(1,0);
    'conditions' => array('mytable.user_type'=>$type)
    

    for single value

    $type = array(1);
    'conditions' => array('mytable.user_type'=>$type)
    

    Hence you just need to manipulate $type as per condition, Hope this work

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

Sidebar

Related Questions

Now I have a long query and I'd like to alternate with such a
I have a long string, like this: 11070, 'EP_LQ-630', 'LQ-630, 24 pin, A4, 360
after a very long sql query a have a result that is in this
I have an NHibernate LINQ query like this: var maxNumber = session .Linq<Child>() .Where(c
Say I have a query like this: SELECT * FROM my_table WHERE name =
I have something like 40K rows and i must run update query like this:
I have the following query which works: SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(42.883, -72.8981)))
I'm trying to build a Hibernate Criteria query to find entities that have a
I have a long LinqtoSQl query in which several parameters I'm not forcing the
I have a reasonably long SQL query that I need to run in 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.