Some more adjustments for DBLayer...

This commit is contained in:
kaetemi 2014-09-03 03:08:22 +02:00
parent e6820c7ac3
commit 4f79a96dea

View file

@ -29,7 +29,7 @@
* *
*/ */
$PDOCache = array(); //$PDOCache = array();
class DBLayer { class DBLayer {
@ -47,23 +47,30 @@ class DBLayer {
*/ */
function __construct($db, $dbn = null) function __construct($db, $dbn = null)
{ {
global $PDOCache; /*global $PDOCache;
if (isset($PDOCache[$db])) { if (isset($PDOCache[$db])) {
$this->PDO = $PDOCache[$db]; $this->PDO = $PDOCache[$db];
} else { } else {*/
global $cfg; global $cfg;
$dsn = "mysql:"; $dsn = "mysql:";
$dsn .= "host=" . $cfg['db'][$db]['host'] . ";"; $dsn .= "host=" . $cfg['db'][$db]['host'] . ";";
$dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";"; $dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";";
$dsn .= "port=" . $cfg['db'][$db]['port'] . ";"; $dsn .= "port=" . $cfg['db'][$db]['port'] . ";";
//$dsn .= "charset=utf8;";
$opt = array( $opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_PERSISTENT => false
); );
$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);
$PDOCache[$db] = $this->PDO; //$PDOCache[$db] = $this->PDO;
/*}*/
} }
function __destruct() {
//$this->PDO->query('KILL;');
$this->PDO = NULL;
} }
/** /**