コード例 #1
0
 public function updateAllEvent(ICalendarEvent $event)
 {
     try {
         $dbHandler = $this->getConnection();
         $data = array(CalendarManager::EVENT_KEY_ID => $event->getId(), CalendarManager::EVENT_KEY_SUBJECT => $event->getSubject(), CalendarManager::EVENT_KEY_LOCATION => $event->getLocation(), CalendarManager::EVENT_KEY_DESCRIPTION => $event->getDescription(), CalendarManager::EVENT_KEY_ISALLDAY => $event->getIsAllDay(), CalendarManager::EVENT_KEY_TYPE => $event->getType(), CalendarManager::EVENT_KEY_PRIVACY => $event->getPrivacy(), CalendarManager::EVENT_KEY_CREATORID => $event->getCreatorId(), CalendarManager::EVENT_KEY_CALENDARID => $event->getCalendarId());
         $sqlQuery = 'UPDATE ' . self::EVENT_TABLE_NAME . ' SET ';
         foreach ($data as $key => $value) {
             if ($key != CalendarManager::EVENT_KEY_ID) {
                 $sqlQuery .= $key . ' = :' . $key . ', ';
             }
         }
         $sqlQuery = substr($sqlQuery, 0, -2);
         $sqlQuery .= ' WHERE ' . CalendarManager::EVENT_KEY_ID . ' = :' . CalendarManager::EVENT_KEY_ID;
         $stmt = $dbHandler->prepare($sqlQuery);
         $stmt->execute($data);
     } catch (Exception $e) {
         $this->destroyConnection();
         throw new EyeDBException('An error occured while attempting to update event with ID "' . $event->getId() . '".', 0, $e);
     }
     $this->destroyConnection();
 }