private function createConnection($host)
 {
     $dbconfig = $this->config;
     $db = new MooMySQL();
     $db->connect($host, $dbconfig['username'], $dbconfig['password'], $dbconfig['dbname'], $dbconfig['pconnect'], $dbconfig['encoding']);
     return $db;
 }
 public function inserttable($tablename, $insertsqlarr, $returnid = 0, $replace = false, $silent = 0)
 {
     $this->setWriteConn();
     $insertkeysql = $insertvaluesql = $comma = '';
     foreach ($insertsqlarr as $insert_key => $insert_value) {
         $insertkeysql .= $comma . '`' . $insert_key . '`';
         $insertvaluesql .= $comma . '\'' . $insert_value . '\'';
         $comma = ', ';
     }
     $method = $replace ? 'REPLACE' : 'INSERT';
     self::$write_conn->query($method . ' INTO ' . $this->tname($tablename) . ' (' . $insertkeysql . ') VALUES (' . $insertvaluesql . ') ', $silent ? 'SILENT' : '');
     if ($returnid && !$replace) {
         $insert_id = self::$write_conn->insertId();
     } else {
         $insert_id = false;
     }
     return $insert_id;
 }
 /**
  * 获取内部使用的连接
  * @return MooMySQL
  */
 private function getConnection($re_select_db = true)
 {
     if (!isset($this->conn)) {
         $this->conn = $this->getDriver();
         if ($this->config['pconnect'] == 'false' || !$this->config['pconnect']) {
             $pconnect = false;
         } else {
             $pconnect = true;
         }
         $this->conn->connect($this->config['host'], $this->config['username'], $this->config['password'], $pconnect, $this->config['charset'], $this->config['newlink']);
         if ($this->logger->isDebugEnabled()) {
             $this->logger->writeDebug("[db_helper=%s]tring to connect to database[host=%s,username=%s,database=%s,pconnect=%s,charset=%s,newlink=%s]", array(spl_object_hash($this), $this->config['host'], $this->config['username'], $this->config['database'], $pconnect, $this->config['charset'], $this->config['newlink']));
         }
     }
     if ($re_select_db) {
         $this->conn->selectDB($this->config['database'], $this->config);
     }
     return $this->conn;
 }