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; }
/** * 获取内部使用的连接 * @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; }