-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogEventDao.php
37 lines (34 loc) · 951 Bytes
/
LogEventDao.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
<?php
class LogEventDao {
private $table = 'atp_log_event';
public function __construct($link) {
$this->link = $link;
}
public function add($event) {
$query = "INSERT INTO ".$this->table." (date, notes) values (";
$query .= $this->prepareDate($event->getDate()).", ";
$query .= $this->prepareStr($event->getNotes())." ";
$query .= ");" ;
mysqli_query($this->link, $query);
}
public function clear() {
$query="DELETE FROM ".$this->table.";";
mysqli_query($this->link, $query);
}
protected function prepareDate($str) {
if ($str ==null) {
return "null";
} else {
$result = date("Y-m-d H:i:s", strtotime($str));
return " '$result' ";
}
}
protected function prepareStr($str) {
if ($str ==null) {
return "null";
} else {
return " '".mysqli_real_escape_string($this->link, $str)."' ";
}
}
}
?>