Hello there, 

I have a task to modify a quite problematic calendar that wasn't created
by me -- currently only weeks and months are shown (for that, all days
of the week/month are looped through). For every day, 7 queries are done
-- one for each table (there are different tables for weekly, monthly,
annually etc recurring events). When there is an event for that day in a
particular table, then the DetailsID will be returned and the details
table will be queried about closer information regarding the event
(time, name, desc etc). 

I don't really think that looping though the entire year would be such a
wise idea (that would be 365 * 7 queries sent to mySQL database). Can
you think of an alternative? 

The queries are as shown below. 

///////   nr. 1
SELECT CalendarDetailsID
        FROM phpCalendar_Daily
        WHERE ".$LocQuery." AND Active = '1' AND
        ( ('$queryDate' = StartDate AND StopDate = '0000-00-00') OR
        (StopDate != '0000-00-00' AND '$queryDate' BETWEEN StartDate AND
StopDate) )

///////   nr. 2

SELECT CalendarDetailsID
        FROM phpCalendar_Daily
        WHERE ".$LocQuery." AND Active = '1' AND
        ( ('$queryDate' = StartDate AND StopDate = '0000-00-00') OR
        (StopDate != '0000-00-00' AND '$queryDate' BETWEEN StartDate AND
StopDate) )

///////   nr. 3

SELECT CalendarDetailsID, DaysOfWeek
        FROM phpCalendar_Weekly
        WHERE ".$LocQuery." AND Active = '1' AND
        ( ('$queryDate' >= DisplayStart AND DisplayStop = '0000-00-00')
OR
        (DisplayStop != '0000-00-00' AND '$queryDate' BETWEEN
DisplayStart AND DisplayStop) )

///////   nr. 4

SELECT CalendarDetailsID
        FROM phpCalendar_Monthly
        WHERE ".$LocQuery." AND Active = '1' AND DayOfMonth = '$q' AND
        ( ('$queryDate' >= DisplayStart AND DisplayStop = '0000-00-00')
OR
        (DisplayStop != '0000-00-00' AND '$queryDate' BETWEEN
DisplayStart AND DisplayStop) )

///////   nr. 5

SELECT CalendarDetailsID
        FROM phpCalendar_Yearly
        WHERE ".$LocQuery." AND Active = '1' AND DayOfMonth = '$q' AND
Month = '$Month' AND
        ( ('$queryDate' >= DisplayStart AND DisplayStop = '0000-00-00')
OR
        (DisplayStop != '0000-00-00' AND '$queryDate' BETWEEN
DisplayStart AND DisplayStop) )

///////   nr. 6

SELECT CalendarDetailsID, WeekDays
        FROM phpCalendar_PeriodicalMonthly
        WHERE ".$LocQuery." AND Active = '1' AND WeekNumber =
'$numOfTodays' AND
        ( ('$queryDate' >= DisplayStart AND DisplayStop = '0000-00-00')
OR
        (DisplayStop != '0000-00-00' AND '$queryDate' BETWEEN
DisplayStart AND DisplayStop) )

///////   nr. 7

SELECT CalendarDetailsID, WeekDays
        FROM phpCalendar_PeriodicalYearly
        WHERE ".$LocQuery." AND Active = '1' AND WeekNumber =
'$numOfTodays' AND Month = '$Month' AND
        ( ('$queryDate' >= DisplayStart AND DisplayStop = '0000-00-00')
OR
        (DisplayStop != '0000-00-00' AND '$queryDate' BETWEEN
DisplayStart AND DisplayStop) )




Are there any wiser ways to solve this instead of making 2555 queries
per time the calendar will be requested by a visitor???

TIA

Yours,
Lauri
--
Tharapita Creations
[dynamic web applications]
[EMAIL PROTECTED]
Mobile: +372 53 410 610



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to