Pear::Calendar multiple events woes....
| From: | Michael J. Pawlowsky | Date: | Tue, 21 Sep 2004 16:00:44 +0000 |
| Subject: | Pear::Calendar multiple events woes.... | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14582@lists.php.net to get a copy of this message | ||
Lorenzo Alberton wrote:
I guess I'm the third person, because I didn't receive any mail from you ;)Yes you are... ;-) My question is... I'm having a problem with Pear::Calendar that I'm not exactly sure how to resolve. As an example I will use a Calendar_Month_Weekdays but I'm having the same problem in several Calendars. Basically the problem is that if there is more than 1 event for a day/hour whatever, I believe only the last one is being built into the calendar. Can a day object hold more than one child object in it? Or do I have to create an array of CalEvent objects add that to the selectedDays array before building the Calendar_Month_Weekdays? Any assistance is greatly appreciated. Here's what I am doing: //First I create the Calendar_Month_Weekdays $month = new Calendar_Month_Weekdays(date('Y',$stamp), date('n',$stamp), 0); // Then I query the database for those events $query = "SELECT event_id, event_title, event_location,
event_description, UNIX_TIMESTAMP(event_start) as event_start,UNIX_TIMESTAMP(event_end) as event_end FROM cal_events WHERE MONTH(event_start) = " . date('n',$stamp) . " AND YEAR(event_start) = " . date('Y', $stamp) . " AND event_owner_id = " . $uid . " ORDER BY event_start"; $sql->Query($query); // Create an array to hold Day objects $selectedDays = array (); // Loop through the query and create CalEvent objects with Day objects for($i=0;$i<$sql->rows;$i++){ $sql->fetch($i); $day = new Calendar_Day(date('Y', $sql->data['event_start']),
date('n', $sql->data['event_start']),
date('d', $sql->data['event_start']));
$calEvent = new CalEvent($day);
$calEvent->setEntry($sql->data['event_title']);
$calEvent->setEventID($sql->data['event_id']);
$selectedDays[] = $calEvent;
}
// Instruct month to build day objects$month->build($selectedDays);