-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathmodel.php
More file actions
63 lines (48 loc) · 1.09 KB
/
Copy pathmodel.php
File metadata and controls
63 lines (48 loc) · 1.09 KB
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
56
57
58
59
60
61
62
63
<?php
class Model {
private $connection;
public function __construct()
{
global $config;
$this->connection = new mysqli($config["db_host"],$config["db_username"],$config["db_password"],$config["db_name"]);
}
public function escapeString($string)
{
return mysqli_real_escape_string($this->connection,$string);
}
public function escapeArray($array)
{
$clean = [];
foreach ($array as $key => $value) {
$clean[$key] = mysqli_real_escape_string($this->connection,$value);
}
return $clean;
}
public function to_bool($val)
{
return !!$val;
}
public function to_date($val)
{
return date('Y-m-d', $val);
}
public function to_time($val)
{
return date('H:i:s', $val);
}
public function to_datetime($val)
{
return date('Y-m-d H:i:s', $val);
}
public function query($qry)
{
$result = $this->connection->query($qry) or die('MySQL Error: '. mysqli_error($this->connection));
return $result;
}
public function execute($qry)
{
$exec = mysqli_query($qry) or die('MySQL Error: '. mysqli_error($this->connection));
return $exec;
}
}
?>