-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdao.php
38 lines (37 loc) · 900 Bytes
/
dao.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
<?php
echo "hello from asadi";
class DAO
{
private $host = "127.0.0.1";
private $user = "root";
private $password = "";
private $db = "blog";
private $con = "";
function __construct()
{
$this->con = new mysqli($this->host, $this->user, $this->password, $this->db);
}
function insert($query)
{
return $this->con->query($query);
}
function delete($id, $table)
{
$query = "DELETE FROM " . $table . " WHERE ID=" . $id;
return $this->con->query($query);
}
function update($query)
{
return $this->con->query($query);
}
function selectAll($table)
{
$query = "SELECT * from " . $table;
return $this->con->query($query);
}
function find($id, $table)
{
$query = "SELECT * from " . $table. " WHERE id=".$id;
return $this->con->query($query);
}
}