-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.class.php
37 lines (30 loc) · 838 Bytes
/
db.class.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
<?php
class Database
{
function __construct($dbserver,$dbuser,$dbpassword,$dbname)
{
$this->dbserver=$dbserver;
$this->dbuser=$dbuser;
$this->dbpassword=$dbpassword;
$this->dbname=$dbname;
}
function connect()
{
$this->conn=new mysqli($this->dbserver,$this->dbuser,$this->dbpassword,$this->dbname);
$this->conn->set_charset("utf8");
$this->conn->autocommit(FALSE);
if (!$this->conn OR $this->conn->connect_errno) error(_('DB connection error!'));
return $this->conn;
}
function query($query)
{
$result=$this->conn->query($query);
if (!$result) error(_('DB error').' '.$this->conn->error.' '._('in').': '.$query);
return $result;
}
function insertid()
{
return $this->conn->insert_id;
}
}
?>