I would like to test for appointment conflicts in an app I am working on.
How does this method sound.
I retrieve a start and finish date-time from mysql for each appointment.
I use mktime and obtain a time stamp for each start finish time.
I then create and arrays using
array1 = range(starttime 1, endtime 1)
array2 = range(starttime 2, endtime 2)
I then attempt to use $intersect = array_intersect (array1, array2)
If $intersect is empty no app conflict etc, however this method is probably extremely memory intensive and on my machine times out.
Is the problem that array_intersect requires strings and that range provides arrays of integers.
Maybe someone has a better method of comparison/intersection of two or more date ranges.
Any help appreciated.
Testing for intersection of two date/time ranges
Moderator: General Moderators
i have recently done a similar project, but i tested claseshes in my SQL query like this
if the query returns nothing, then this means that no clash occurs 
Mark
Code: Select all
$startsql = " SELECT * as current_appointment FROM appointments WHERE ((appointment_start < '$start_time' AND appointment_end > '$start_time') OR (appointment_start < '$end_time' AND appointment_end > '$end_time'))";Mark