public function fetch() { global $db; $sql = 'SELECT es.id, es.message, es.start, es.duration, es.icon FROM event_schedule es WHERE es.event = :event ORDER BY start'; $stmt = $db->prepare($sql); $stmt->bindValue(':event', $this->eventId, Database::PARAM_INT); $stmt->execute(); $ret = array(); foreach ($stmt->fetchAll() as $scheduleItem) { $scheduleItem['actions'] = array(); if (Session::hasPriv('SCHEDULE_CHANGE')) { $scheduleItem['actions'][] = '<a href = "?action=delete&schId=' . $scheduleItem['id'] . '&id=' . $this->eventId . '">Delete</a>'; } $scheduleItem['actions'] = implode(', ', $scheduleItem['actions']); $scheduleItem['start'] = formatDtString($scheduleItem['start']); if (!empty($scheduleItem['icon'])) { $scheduleItem['iconUrl'] = 'resources/images/icons/games/' . $scheduleItem['icon']; } else { $scheduleItem['iconUrl'] = null; } $ret[] = $scheduleItem; } return $ret; }
public static function getAllUpcommingEvents() { global $db; $sql = 'SELECT e.id, e.published, e.name, e.date, e.duration, v.name "venue" FROM events e, venues v WHERE e.venue = v.id AND date > curdate() ORDER BY date ASC '; $result = $db->query($sql); $result = $result->fetchAll(); foreach ($result as $k => $event) { // Calculate event ending time. $finish = date_create($event['date']); $finish->modify('+' . $event['duration'] . ' hours'); $result[$k]['date'] = formatDtString($result[$k]['date']); $result[$k]['finish'] = formatDt($finish); } return $result; }
function formatDtIso($date) { $isoStandard = 'Y-m-d H:i'; if (is_string($date)) { return formatDtString($date, $isoStandard); } else { return formatDt($date, $isoStandard); } }