PHP实现的数据库封装类(2)
$config = Core::inHerit($this->default_config,$config);
!in_array($config['dbtype'],array('mysql')) && Core::throwError('未支持的数据库类型');
extract($config);
$this->configs[$index] = $config;
$this->{'_'.$config['dbtype'].'_connect'}($user, $pwd,$host,$dbname,$charset,$index,$port);
}
private function _mysql_connect($user = 'root', $pwd = '' ,$host = 'localhost' ,$dbname = null,$charset = 'utf8' ,$index = 0 ,$port = 3306){
$this->connector[$index] = mysqli_connect ( $host, $user, $pwd , null, $port) or Core::throwError(mysql_error());
$this->active = $index;
if($dbname) $this->selectDb($dbname,$charset);
}
/*取得当前连接*/
private function _getConnect(){
return $this->connector[$this->active];
}
/*取得当前连接使用的数据库类型 带参数自动拼接为函数名*/
private function _getDbTypeFunc($funcname = null){
$dbtype = $this->configs[$this->active]['dbtype'];
return $funcname?'_'.$dbtype.'_'.$funcname
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>