-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbcontroller.php
More file actions
34 lines (30 loc) · 782 Bytes
/
Copy pathdbcontroller.php
File metadata and controls
34 lines (30 loc) · 782 Bytes
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
<?php
class DBController {
private $host = "us-cdbr-iron-east-02.cleardb.net";
private $user = "bb5b8b54ae95cf";
private $password = "2190a897";
private $database = "heroku_9eb67c81329411e";
private $sql_table = "tree";
private $conn;
function __construct() {
$this->conn = $this->connectDB();
}
function connectDB() {
$conn = mysqli_connect($this->host,$this->user,$this->password,$this->database);
return $conn;
}
function runQuery($query) {
$result = mysqli_query($this->conn,$query);
while($row=mysqli_fetch_assoc($result)) {
$resultset[] = $row;
}
if(!empty($resultset))
return $resultset;
}
function numRows($query) {
$result = mysqli_query($this->conn,$query);
$rowcount = mysqli_num_rows($result);
return $rowcount;
}
}
?>