-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabaseManager.php
executable file
·65 lines (57 loc) · 1.12 KB
/
databaseManager.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
- DatabaseManager Class
- Author: Chris Green ([email protected])
- This class handles the database connection, state, and queries
*/
//Includes
//Class
class DatabaseManager
{
//
// Members
//
var $host;
var $databaseName;
var $userName;
var $password;
var $con;
//
// Constructors and destructors
//
function DatabaseManager()
{
//get connection information
//$this->host="yang.lzu.edu.cn";
$this->databaseName="mathpass";
$this->userName="root";
$this->password="890524";
//connect
$this->con=mysql_connect($this->host,$this->userName,$this->password);
if(!$this->con)
{
printf("Can't connect to $this->host. Errorcode: %s\n",mysql_error());
exit;
}
$x=mysql_select_db($this->databaseName,$this->con);
if(!$x)
{
printf("Can't connect to database $dbname. Errorcode: %s\n",mysql_error());
exit;
}
mysql_query("set names 'GBK'");
}
function Dispose()
{
//close connection
@ mysql_close($this->con);
}
//
// Methods
//
function Query($sql)
{
return mysql_query($sql);
}
}
?>