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

  • Home
  • SEARCH
  • 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 8476311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:08:38+00:00 2026-06-10T18:08:38+00:00

For example I have a Store model with fields fromH and toH, I want

  • 0

For example I have a Store model with fields fromH and toH, I want to retrieve stores from database that are open in given hour (@t).

SQL query would look like this

select *
from store 
where 
( fromH < toH and @t between fromH and toH ) or
( fromH > toH and 
     (@t between fromH and 24 OR
     (@t between 1 and toH )
)

How do I implement this query in cakephp, how would the conditions array look? I want to do it cake style.

  • 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-10T18:08:40+00:00Added an answer on June 10, 2026 at 6:08 pm

    Answer given by @Arun Jain is very close to the solution but as the rules for the OR states must each be their own array, because their key values are identical. If you

    print_r($conditions);
    

    you’ll find some of your rules are missing.

    I think following solution will work for you.

    $conditions = array(
        'conditions' => array(
            'OR' => array(
                array(
                    'AND' => array(
                        'fromH <' => 'toH',
                        @t.' BETWEEN ? AND ?' => array('fromH','toH')
                     )
                ),
                array(
                    'AND' => array(
                        'fromH >' => 'toH',
                        'OR' => array(
                            @t.' BETWEEN ? AND ?' => array('fromH','24'),
                            @t.' BETWEEN ? AND ?' => array('1','toH')
                        )
                    )
                )
            )
        )
    );
    
    $this->Strore->find('all',$conditions);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a URL where I am passing in a keyword (http://www.example.com/store?keyword=google). I want
Example: I have an class that inherits from UIImageView. An object creates an instance
I'm using Sencha touch 2. I have store that load from existing js object:
I have a grid panel with JSON store, if I give alert (myGrid.model.prototype.fields.keys), it
Problem I want to save the attributes of a model that have changed when
In rails 3, I have a database model that has a birthday field, of
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I
I have a User model in my app, which I would like to store
How can I add two comboboxes from one store store have type field witch

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.