-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetIndexEvents.php
50 lines (32 loc) · 1.13 KB
/
getIndexEvents.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once 'controller.php';
fORMDatabase::attach(new fDatabase('mysql', SQL_DATABASE, SQL_USER, SQL_PASSWD));
class PhpcEvent extends fActiveRecord{
}
class PhpcOccurrence extends fActiveRecord{
}
//$allEventsArr = CustomDB::getRecords("SELECT phpc_events.* ,phpc_occurrences.* FROM phpc_events RIGHT JOIN phpc_occurrences ON phpc_events.eid = phpc_occurrences.eid");
/* function getLastTwoEvents()
{*/
$allEventsArr = fRecordSet::buildFromSQL('PhpcEvent', "SELECT phpc_events.* FROM phpc_events RIGHT JOIN phpc_occurrences ON phpc_events.eid = phpc_occurrences.eid");
$cnt = 0;
$tmp = '';
$now = new fTimestamp();
foreach ($allEventsArr as $event) {
if ($cnt < 3) {
try {
$occ = new PhpcOccurrence(array('eid' => $event->getEid()));
if ($occ->getStartTs()->lt($now)) {
continue;
}
$cnt++;
$tmp .= '<br>' . $occ->getStartTs()->format('Y-m-d g:ia') . ' - <a href="/alumni/calendar.php?action=display_event&oid=' . $occ->getOid() . '">'. $event->getSubject() .'</a><br>';
} catch (Exception $e) {
echo $e->getMessage();
}
}
# code...
}
echo $tmp;
/* }*/
?>