-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEvent.php
55 lines (51 loc) · 1.38 KB
/
Event.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
51
52
53
54
55
<?php
/**
* Created by PhpStorm.
* User: selly
* Date: 5/5/15
* Time: 3:04 PM
*/
namespace greenbase;
class Event {
public $id;
public $datetime;
public $organization_id;
public $user_id;
public $headline;
public $event_text;
public static function getEventsForOrg($org_id, $con) {
$query = "SELECT id, datetime, organization_id, user_id, headline, event_text FROM events WHERE organization_id=?";
$stmt = $con->prepare($query);
$stmt->bind_param("i", $org_id);
$stmt->execute();
$id = $datetime = $organization_id = $user_id = $headline = $event_text = null;
$stmt->bind_result($id, $datetime, $organization_id, $user_id, $headline, $event_text );
$result = [];
while ($stmt->fetch()) {
$event = new Event();
$event->id = $id;
$event->datetime=$datetime;
$event->organization_id=$organization_id;
$event->user_id=$user_id;
$event->headline=$headline;
$event->event_text=$event_text;
$result[]= $event;
}
$stmt->close();
return $result;
}
public function printSimpleEventBlock() {
if (!is_null($this->user_id)) {
echo ("User (");
echo ($this->user_id);
} else {
echo ("Organization (");
echo($this->organization_id);
}
echo (") said ");
echo htmlspecialchars($this->headline);
echo (":");
echo htmlspecialchars($this->event_text);
}
}
?>