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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:47:38+00:00 2026-06-15T02:47:38+00:00

I am trying to build a restaurant table management application using yii framework currently

  • 0

I am trying to build a restaurant table management application using yii framework currently i am stuck with retrieving availability of tables for a particular time

i have the following tables

below image shows the table structure i have

enter image description here

i am getting the avaiable table by using the following piece of code

    $model = new Table;
    $criteria = new CDbCriteria;
    $criteria->condition = 'floor_id=' . $floorid;
    $rows = $model->model()->with(array(
                'bookingTables' => array(
                    'condition' => 'bookingTables.table_id IS NULL'
                    )))->findAll($criteria);

this works only when the table ids are not present in the booking_table table

suppose if say the booking_table table has table ids filled then above code will not work it will always return as not available (no clue how to use time to get available tables)

so how can i get the available tables for a particular time period any solution in yii or sql

  • 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-15T02:47:39+00:00Added an answer on June 15, 2026 at 2:47 am

    Since you accept both SQL and YII, I give you a solution in SQL.

    If you want to check availability at a given time, you need to know the reservation date (that includes the hour), so let’s consider that we add the field ‘reservation_date’ in your ‘booking_table’ table, and let’s consider a booking ends 2 hours after it has started.
    This is what I’ll do in SQL :

    SELECT t.table_id
    FROM TABLE AS t
    LEFT OUTER JOIN booking_table AS b ON b.booking_table_id = t.table_id
    WHERE b.booking_id IS NULL
        OR DATE_ADD(NOW(), INTERVAL 2 HOUR) > b.reservation_date
    

    This query lists all available tables at the time its executed. If you want to check availability at a specific time, replace ‘NOW()’ by whatever you need.

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

Sidebar

Related Questions

I'm trying build my application using REST and Spring MVC. For some entities I
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build an App Engine connected Android application and am having some problems
I'm trying build a MVC framework, but I'm confused about manage themes. Well... I
I am trying build small webcam chat (web application). I searched on google and
I am trying build a DataTable one row at a time using the following
Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object
I am trying build a page, where a user can login using his google
Trying to build a GUI application in Java/Swing. I'm mainly used to painting GUIs
Im trying to build and automated log in using Googles authSub, but I need

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.