-
Notifications
You must be signed in to change notification settings - Fork 4
/
db.php
25 lines (18 loc) · 953 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
<?php
class DB {
public static function getDBConnection() {
//Parse site configuration file into array
$siteprop_array = parse_ini_file("siteproperties.ini");
//connect to database
error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );
//Remove this mysql_connect statement once all outdated queries are removed.
mysql_connect($siteprop_array["db_host"],$siteprop_array["db_username"],$siteprop_array["db_password"]) or die(mysql_error());
mysql_select_db($siteprop_array["db_name"]) or die(mysql_error());
//there's an error here when including the charset, figure out later
$db = new PDO($siteprop_array["db_driver"].':host='.$siteprop_array["db_host"].';dbname='.$siteprop_array["db_name"],
$siteprop_array["db_username"],$siteprop_array["db_password"],
array(PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
return $db;
}
}