-
Notifications
You must be signed in to change notification settings - Fork 0
/
_db.lost.php
30 lines (24 loc) · 1.31 KB
/
_db.lost.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
<?php
require_once('_db.php');
class LostDB extends IWU_DB {
public function __construct() {
$this->dbn = 'LostAndFound';
parent::__construct();
}
public function getCurrentItems() {
$stmt = $this->dbh->prepare('SELECT ItemNo, ItemName, Location, Description, Date, Date_Reported, Email, ContactName, "lost" AS Type FROM TB_Lost_Items WHERE (TO_DAYS(CURDATE()) - TO_DAYS(Date_Reported)) <= 10 UNION SELECT ItemNo, ItemName, Location, Description, Date, Date_Reported, Email, ContactName, "found" AS Type FROM TB_Found_Items WHERE (TO_DAYS(CURDATE()) - TO_DAYS(Date_Reported)) <= 10 ORDER BY Date_Reported DESC');
$stmt->execute();
$result = array();
while($row = $stmt->fetch()) {
$result[] = new LostItem($row);
}
return $result;
}
}
class LostItem extends IWU_DataRow {
public function __toString() {
$result = '<div class="post content_block '.$this->row['Type'].'"><h1>'.$this->row['ItemName'].'</h1><h2>'.$this->row['ContactName'].'<br /><a href="mailto:' . $this->row['Email'] . '">' . $this->row['Email'] . '</a></h2><h3><span class="type">'.$this->row['Type'].'</span> '.date('F j', strtotime($this->row['Date'])).'</h3><p class="description"><em>Description:</em> '.$this->row['Description'].'</p><p class="location"><em>Where was it?</em> '.$this->row['Location'].'</p></div>';
return $result;
}
}
?>