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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:01:39+00:00 2026-05-26T06:01:39+00:00

I am getting a list of Rate information from the database with conditions. However

  • 0

I am getting a list of Rate information from the database with conditions. However I wish to add another condition of minimum Stay if the date range has a date in it and rateID form another table called minimum stay. The Rate table already has a min stay but on certain dates I want to over ride this if the date falls within the date range I pass.

I am new to cakephp so I am unsure how to check the minStay table for dates in the date range. Then get the largest minStay and the add it to the condition.

Default minStay in Rate table is 1

Here is the data in the minStay table:

date:31-10-2011 rateID:21 minStay:2
date:1-11-2011 rateID:21 minStay:3

Results: If date range is 31-10-2011 to 2-11-2011 / 2 nights then no results. If 3 nights or more then result.

I hope I have explaind that correctly.

Variable containing the date range is $todays

        $conditions = array(
                'Rate.enabled'=>1,'Rate.is_corporate'=>$is_corporate, 'Rate.minimum_stay <='=>$days, 
                'Rate.valid_from < '=>$date_start,'Rate.valid_to >'=>$date_end,
                'OR'=>array('Rate.maximum_stay'=>0,'Rate.maximum_stay >='=>$days)
        );

        $order = 'Rate.list_no';
        $this->Rate->contain('Room.id','Room.title','Room.max_adults','Room.max_children');
        $rates = $this->Rate->find('all',array('conditions'=>$conditions,'order'=>$order));
  • 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-26T06:01:40+00:00Added an answer on May 26, 2026 at 6:01 am

    I think i understood what you want to do, if not please comment.

    To do that you need to do somthing like this (assuming you have something like has many MinStay)

        $conditions = array(
                'Rate.enabled'=>1,'Rate.is_corporate'=>$is_corporate, 'Rate.minimum_stay <='=>$days, 
                'Rate.valid_from < '=>$date_start,'Rate.valid_to >'=>$date_end,
                'OR'=>array('Rate.maximum_stay'=>0,'Rate.maximum_stay >='=>$days),
                'AND' => array('OR'=> array('minStay.date BETWEEN ? AND ?' => array($date_start,$date_end)),
                     'minStay.minimum_stay <' =>$days )
        );
    
        $order = 'Rate.list_no';
        $fields = array ('Room.id','Room.title','Room.max_adults','Room.max_children');
        $rates = $this->Rate->find('all',array('conditions'=>$conditions,'order'=>$order, 'fields'=> $fields));
    

    I think that will do it, hope it works for you

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

Sidebar

Related Questions

I am getting from database list of items ordered by descending date. I use
I am getting a list of products from my database as a BindingList. I
I am getting list of data from database from my Service Class Method mDataVO.getMarketData()
i am getting a list of items from sqlite database and place them in
I am populating the list view with data I am getting from a JSON
I keep getting this error in the $('#savetickets-list') line. I want to dynamically add
i am getting list of video files from web services and playing in Videoview
I am implementing a project in which I am getting the product list from
I have below code now. I am getting list of strings from the UI
I am developing an Iphone monotouch application. I am getting list of locations from

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.