forked from chriscareycode/nagiostv-ndoutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.php
42 lines (35 loc) · 883 Bytes
/
db.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 DB {
var $link;
var $my_host = "";
var $my_db = "";
var $my_user = "";
var $my_pass = "";
function construct($p_host, $p_db, $p_user, $p_pass) {
$this->my_host = $p_host;
$this->my_db = $p_db;
$this->my_user = $p_user;
$this->my_pass = $p_pass;
}
function connect() {
$this->link = mysql_connect($this->my_host, $this->my_user, $this->my_pass);
if (!$this->link) {
printf("Error: Connection to MySQL server '%s' as user '%s' failed.<BR>\n", $this->my_host, $this->my_user);
return;
}
}
function select() {
mysql_select_db($this->my_db);
}
function query($p_sql) {
$result = mysql_query($p_sql, $this->link)
or die ("Error: [$p_sql] - <b>" . mysql_error($this->link) . "</b>" );
return $result;
}
function disconnect() {
if (!mysql_close($this->link)) {
die("Could not close DB");
}
}
}
?>