-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbhandler.php
More file actions
executable file
·55 lines (46 loc) · 1.1 KB
/
dbhandler.php
File metadata and controls
executable file
·55 lines (46 loc) · 1.1 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
<?php
class DbHandler{
private $hostname;
private $username;
private $passowrd;
private $name;
protected $_db_connect;
protected $_sql;
/**
* Database construcor.
*
* @param hostname
* @param username
* @param password
*/
function __construct($hostname, $username, $passowrd){
$this->hostname = $hostname;
$this->username = $username;
$this->passowrd = $passowrd;
}
function connect(){
// $this->_db_connect = mysqli_connect($this->hostname, $this->username, $this->passowrd) or die(mysql_error());
$this->_db_connect = new mysqli($this->hostname, $this->username, $this->passowrd);
}
function select_db($name){
$this->name = $name;
$this->_db_connect->select_db($this->name) or die(mysql_error());
}
/**
*Select all.
*/
function selectAll($tableName){
return $this->query('SELECT * FROM ' .$tableName);
}
/**
*Run query.
*/
function query($queryString){
$queryResult = $this->_db_connect->query($queryString);
return $queryResult;
}
function db_close(){
mysql_close($this->_db_connect);
}
}
?>