I'm Developing booking website in cakephp. Im little struck in query writing.
If user tries to book from "2015-12-11 08:00:00" to "2015-12-11 16:00:00".
how to i select from table that it is already booked or not.
Ex: If already one person booked from 6am to 9am means it should not allow. I have used below query but its not fetching correctly i think.
SELECT * FROM `items`
WHERE ((`fromdate` < '2015-12-11 08:00:00' AND `todate` < '2015-12-11 16:00:00')
OR (`fromdate` > '2015-12-11 08:00:00' AND `todate` > '2015-12-11 16:00:00')) AND status=1;