Problem with database query |
I have 2 tables in database.
I need to get from database all rooms in which there is no reservation in the hours and date given by me. rooms Quote:id int(11) reservations Quote:id int(11) My function: PHP Code: public function get_free_rooms() { My reservations table is empty now. When I give data: Quote:$date = 2019-05-29, $time_start = 10:00:00, $time_finish = 13:00:00 result of query is an empty array and should return all rooms because there is no booking.
After you run your query did you use
PHP Code: $temp = $this->db->last_query(); To see what your query looks like? What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@InsiteFX, $temp return this:
Quote:SELECT * FROM `rooms` LEFT JOIN `reservations` ON `rooms`.`id` = `reservations`.`room_id` and `reservations`.`date` = '2019-05-29' and `reservations`.`time_start`<='10:00' and `reservations`.`time_finish`>='13:00' WHERE reservations.id IS NULL @php_rocs, yes. Reservations are only for one day. |
Welcome Guest, Not a member yet? Register Sign In |