Exemplo n.º 1
0
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 2
0
 /**
  * 开启主从数据库同步时,不同的操作类型将分配不同的服务器进行处理
  * @access private
  * @param string $type 数据库操作类型  SELECT | ADD |UPDATE | REMOVE
  * @return void
  */
 protected function _allotDatabaseServer($type = 'SELECT')
 {
     if ($this->_db_drive_connect == NULL) {
         $this->_selectDatabaseServer();
         $this->_db_drive_connect = XF_Db_Drive_Mysql::getInstance();
     }
     if ($this->_open_slave && $type == 'SELECT') {
         //if(rand(0, 1) == 0 && $this->_slave_db_count ==1 )
         //	$this->_db_drive_connect->setDatabaseConnectionConfigInfo($this->_db_config);
         //else
         $this->_db_drive_connect->setDatabaseConnectionConfigInfo($this->_slave_db_config);
     } else {
         $this->_db_drive_connect->setDatabaseConnectionConfigInfo($this->_db_config);
     }
     $this->_db_drive_connect->setDatabaseName($this->_db_table->getDbName());
 }