-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.php
42 lines (29 loc) · 843 Bytes
/
post.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
<?php
class Post
{
protected $db = null;
public function __construct(dbcontroller $db)
{
if (!isset($db->con)) return null;
$this->db = $db;
}
public function getTableData($table = 'posts')
{
$result = $this->db->con->query("SELECT * FROM {$table} ORDER BY ts DESC");
$resultarray = array();
while ($item = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$resultarray[] = $item;
}
return $resultarray;
}
public function getRows($table = 'posts')
{
$res = $this->db->con->query("SELECT COUNT(*) FROM {$table}");
$resarray = array();
while ($it = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$resarray[] = $it;
}
return $resarray;
}
}
?>