コード例 #1
0
ファイル: Db.php プロジェクト: uwitec/outbuying
 /**
  * 使用只读数据库连接
  *
  * @author bobit
  * Mon Sep 24 16:37:49 CST 200716:37:49
  */
 public function useReadonlyDb()
 {
     //$old_db_host 未被使用 by terry at Thu Feb 19 11:37:44 CST 2009
     //$old_db_host = $this->_getDbConnectionHost();
     if (!self::$_readDbServerNameOfThisSession) {
         $int = mt_rand(1, 3);
         self::$_readDbServerNameOfThisSession = 'read' . $int;
     }
     //Watt_Log::addLog("[{$this->_getDbConnectionHost()}-{$this->_conn}]Prepare change connection to READONLY DB server", Watt_Log::LEVEL_DEBUG, 'DB_CONTROL', '', '',  __FILE__.__LINE__);
     $this->reconnect(self::$_readDbServerNameOfThisSession);
     //Watt_Log::addLog("[{$this->_getDbConnectionHost()}-{$this->_conn}]Connection was changed", Watt_Log::LEVEL_DEBUG, 'DB_CONTROL', '', '', __FILE__.__LINE__);
     if ($this->_debug) {
         Watt_Debug::addInfoToDefault('', "Connected to READONLY DB server[{$this->_getDbConnectionHost()}:{$this->_conn}]");
     }
 }