-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.inc.php
More file actions
36 lines (31 loc) · 898 Bytes
/
sql.inc.php
File metadata and controls
36 lines (31 loc) · 898 Bytes
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
<?php
// class for the database management
class Sql {
private $server = 'localhost';
private $user = 'root';
private $password = '';
private $database = 'ipt';
private $mysql_connection;
// initializes a mysql connection with data given in the attributes
public function __construct() {
if ( ! ($this->mysql_connection = mysql_connect($this->server, $this->user, $this->password)) ) {
die('Connection to database failed');
}
if ( ! mysql_select_db($this->database) ) {
die('Connection to database failed');
}
}
// shortcut for the mysql_fetch_object function
public function fetch($query) {
return mysql_fetch_object(mysql_query($query));
}
// shortcut for the mysql_query function
public function query($query) {
return mysql_query($query);
}
// closes the mysql connection
public function __destruct() {
mysql_close($this->mysql_connection);
}
}
?>