I have a simple calendar on PHP and MySQL, it stores events in a simple format:
id int
name varchar
start datetime
end datetime
What I need to do, and can’t find a reliable way to do it, is to “block” certain time slot so that there can’t be any other event in that time window.
What I’m trying to find basically is the mysql query to check if the new selected time frame is occupied:
If I go this way:
SELECT * FROM events WHERE new_event_start => start AND new_event_end =< end;
It fails to find an event that starts before new_event_start and ends after new_event_end
Any ideas?
This is a logic question, not a language or technology question.
You need to test for several cases:
That will catch all events that would overlap a blocked period.