|
|
@ -14,8 +14,10 @@ class DBLayer{
|
|
|
|
* Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var)
|
|
|
|
* Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var)
|
|
|
|
* @param $db String, the name of the databases entry in the $cfg global var.
|
|
|
|
* @param $db String, the name of the databases entry in the $cfg global var.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function __construct($db)
|
|
|
|
function __construct($db, $dbn = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($db != "install"){
|
|
|
|
|
|
|
|
|
|
|
|
global $cfg;
|
|
|
|
global $cfg;
|
|
|
|
$dsn = "mysql:";
|
|
|
|
$dsn = "mysql:";
|
|
|
|
$dsn .= "host=". $cfg['db'][$db]['host'].";";
|
|
|
|
$dsn .= "host=". $cfg['db'][$db]['host'].";";
|
|
|
@ -27,6 +29,18 @@ class DBLayer{
|
|
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
|
|
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
|
|
|
|
);
|
|
|
|
);
|
|
|
|
$this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt);
|
|
|
|
$this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
global $cfg;
|
|
|
|
|
|
|
|
$dsn = "mysql:";
|
|
|
|
|
|
|
|
$dsn .= "host=". $cfg['db'][$dbn]['host'].";";
|
|
|
|
|
|
|
|
$dsn .= "port=". $cfg['db'][$dbn]['port'].";";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$opt = array(
|
|
|
|
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
|
|
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->PDO = new PDO($dsn,$_POST['Username'],$_POST['Password'], $opt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|