您现在的位置:主页 > 技术中心 > WEB编程 > PHP

PHP实现的数据库封装类(2)

来源:互联网 责任编辑:admin 发表时间:2013-07-01 17:48 点击:

     $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

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片

推荐热点

  • PHP测试
  • 十天学会php之第六天
  • 几种显示数据的方法的比较
  • 使用xmlhttp为网站增加域名查询功能
  • PHP+MYSQL+Javascript数据库查询结果的动态显示
  • 查找数组中指定键名的值
  • 用redis实现跨服务器session
  • 用新浪微博接口发送图片微博失败的原因
  • smarty局部缓存技术[源码分析]
?? - ?? - ÝřŝžľŘÝź - TAGąęÇŠ - RSSśŠÔÄ - ??
Copyright © 2004-2024 上海卓卓网络科技有限公司