public function start_db()
 {
     parent::start_db();
     if (isset($this->_config['read'])) {
         $random_server = array_rand($this->_config['read'], 1);
         $this->_config['host'] = $this->_config['read'][$random_server]['host'];
         if (isset($this->_config['read'][$random_server]['port'])) {
             $this->_config['port'] = $this->_config['read'][$random_server]['port'];
         }
     }
     if (isset($this->_config['port'])) {
         $server = $this->_config['host'] . ':' . $this->_config['port'];
     } else {
         $server = $this->_config['host'];
     }
     if (isset($this->_config['write'])) {
         $random_server = array_rand($this->_config['write'], 1);
         $writeserver = $this->_config['write'][$random_server]['host'];
         if (isset($this->_config['write'][$random_server]['port'])) {
             $writeserver .= ':' . $this->_config['write'][$random_server]['port'];
         }
         if (!($this->writeDB = mysql_connect($writeserver, $this->_config['user'], $this->_config['pass']))) {
             throw new Exception('cant connect to server ' . $writeserver);
         }
         if (!mysql_select_db($this->_config['dbname'], $this->writeDB)) {
             throw new Exception('cant change to dbname of database ' . $this->_config['database'] . ' on server ' . $writeserver);
         }
     }
     if (!($this->DB = mysql_connect($server, $this->_config['user'], $this->_config['pass']))) {
         throw new Exception('cant connect to server ' . $server);
     }
     if (!mysql_select_db($this->_config['dbname'], $this->DB)) {
         throw new Exception('cant change to dbname of database ' . $this->_config['database'] . ' on server ' . $server);
     }
 }