mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Some more adjustments for DBLayer...
This commit is contained in:
parent
6fed8bad5b
commit
bf7a91b3fc
1 changed files with 13 additions and 6 deletions
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
$PDOCache = array();
|
||||
//$PDOCache = array();
|
||||
|
||||
class DBLayer {
|
||||
|
||||
|
@ -47,23 +47,30 @@ class DBLayer {
|
|||
*/
|
||||
function __construct($db, $dbn = null)
|
||||
{
|
||||
global $PDOCache;
|
||||
/*global $PDOCache;
|
||||
if (isset($PDOCache[$db])) {
|
||||
$this->PDO = $PDOCache[$db];
|
||||
} else {
|
||||
} else {*/
|
||||
global $cfg;
|
||||
$dsn = "mysql:";
|
||||
$dsn .= "host=" . $cfg['db'][$db]['host'] . ";";
|
||||
$dsn .= "dbname=" . $cfg['db'][$db]['name'] . ";";
|
||||
$dsn .= "port=" . $cfg['db'][$db]['port'] . ";";
|
||||
//$dsn .= "charset=utf8;";
|
||||
|
||||
$opt = array(
|
||||
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);
|
||||
$PDOCache[$db] = $this->PDO;
|
||||
}
|
||||
//$PDOCache[$db] = $this->PDO;
|
||||
/*}*/
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
//$this->PDO->query('KILL;');
|
||||
$this->PDO = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue