-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.php
More file actions
22 lines (18 loc) · 765 Bytes
/
db.php
File metadata and controls
22 lines (18 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
class DB {
public static function Connect(){
require_once('config/config.php');
global $CONFIG;
return DB::ConnectWithCred($CONFIG["db_type"], $CONFIG["mysql_server"], $CONFIG["database"], $CONFIG["database_user"], $CONFIG["database_pswd"]);
}
public static function ConnectWithCred($db_type,$sql_server, $db, $user, $password){
if(!isset($db_type) || $db_type == 0)
$dbco = new PDO("mysql:host=".$sql_server.";dbname=".$db, $user, $password);
else{
$dbco = new PDO('sqlite:'.dirname(__FILE__).'/data/database.sqlite');
}
$dbco->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbco->beginTransaction();
return $dbco;
}
}