-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbutil.php
49 lines (44 loc) · 911 Bytes
/
dbutil.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
43
44
45
46
47
48
49
<?php
include "server_vars.php";
class Database
{
private $mysqli;
private $results;
function __construct($hostname, $username, $password, $dbname)
{
//constructor to instantiate a new db. All db related crap will happen with $mysqli.
$mysqli = new mysqli($hostname, $username, $password, $dbname);
}
function select($table, $fields, $where, $condition_fields, $condition_values)
{
$query = "SELECT ";
for($i=0;$i<count($fields);$i++)
{
$query .= $fields[$i] . " ";
}
$query .= "FROM " . $table . "";
if($where == 1)
{
$query .= " WHERE ";
for($i=0;$i<count($condition_fields);$i++)
{
$query .= $condition_fields[$i];
$query .= "=?"
if(($i+2) != count($condition_fields))
{
$query .= " AND ";
}
else
{
break;
}
}
$query .= $condition_fields[$i+1];
}
if($q1 = $mysqli->prepare($query))
{
$mysqli =
}
}
}
?>