示例#1
0
 /**
  * Get a reference to the only instance of database class and connects to DB
  *
  * if the class has not been instantiated yet, this will also take
  * care of that
  *
  * @static
  * @return      object  Reference to the only instance of database class
  */
 public static function instance()
 {
     if (self::$xoopsInstance !== false) {
         return self::$xoopsInstance;
     }
     $allowWebChanges = defined('XOOPS_DB_PROXY') ? false : true;
     if (substr(XOOPS_DB_TYPE, 0, 4) == 'pdo.') {
         self::$xoopsInstance = new icms_db_legacy_PdoDatabase(self::$pdoInstance, $allowWebChanges);
     } else {
         if (defined('XOOPS_DB_ALTERNATIVE') && class_exists(XOOPS_DB_ALTERNATIVE)) {
             $class = XOOPS_DB_ALTERNATIVE;
         } else {
             $class = 'icms_db_legacy_' . XOOPS_DB_TYPE;
             $class .= $allowWebChanges ? '_Safe' : '_Proxy';
         }
         self::$xoopsInstance = new $class();
         self::$xoopsInstance->setLogger(icms::$logger);
         if (!self::$xoopsInstance->connect()) {
             icms_loadLanguageFile('core', 'core');
             trigger_error(_CORE_DB_NOTRACEDB, E_USER_ERROR);
         }
     }
     self::$xoopsInstance->setPrefix(XOOPS_DB_PREFIX);
     return self::$xoopsInstance;
 }
示例#2
0
 public function __construct()
 {
     parent::__construct();
     $this->_errors = icms_core_Debug::setDeprecated('icms_db_legacy_database', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
 }
示例#3
0
 public function __construct($connection, $allowWebChanges = false)
 {
     parent::__construct($connection, $allowWebChanges);
     $this->pdo = $connection;
 }