'DB_TYPE' => 'mysql', 'DB_HOST' => '192.168.5.102', 'DB_NAME' => 'databasename', 'DB_USER' => 'user', 'DB_PWD' => 'password', 'DB_PORT' => '3306', 'DB_PREFIX' => 'onmpw_',
'DB_TYPE' => 'mysql', 'DB_HOST' => '192.168.5.191,192.168.5.88,192.168.5.103', 'DB_NAME' => 'test,test,test', 'DB_USER' => 'masteruser,slaveuser,slaveuser', 'DB_PWD' => 'masterpass,slavepass,slavepass', 'DB_PORT' => '3306', 'DB_PREFIX' => '', 'DB_DEPLOY_TYPE' => 1, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 'DB_RW_SEPARATE' => true, // 数据库读写是否分离 主从式有效 'DB_MASTER_NUM' => 1, // 读写分离后 主服务器数量 'DB_SLAVE_NO' => '', // 指定从服务器序号
$_config['username'] = explode(',',$this->config['username']);
$_config['password'] = explode(',',$this->config['password']);
$_config['hostname'] = explode(',',$this->config['hostname']);
$_config['hostport'] = explode(',',$this->config['hostport']);
$_config['database'] = explode(',',$this->config['database']);
$_config['dsn'] = explode(',',$this->config['dsn']);
$_config['charset'] = explode(',',$this->config['charset']);
protected function initConnect($master=true) {
if(!empty($this->config['deploy']))
// 采用分布式数据库
$this->_linkID = $this->multiConnect($master);
else
// 默认单数据库
if ( !$this->_linkID ) $this->_linkID = $this->connect();
}
if($this->config['rw_separate']){
// 主从式采用读写分离
if($master)
// 主服务器写入
$r = $m;
else{
if(is_numeric($this->config['slave_no'])) {// 指定服务器读
$r = $this->config['slave_no'];
}else{
// 读操作连接从服务器
$r = floor(mt_rand($this->config['master_num'],count($_config['hostname'])-1)); // 每次随机连接的数据库
}
}
}else{
// 读写操作不区分服务器
$r = floor(mt_rand(0,count($_config['hostname'])-1)); // 每次随机连接的数据库
}
$m = floor(mt_rand(0,$this->config['master_num']-1));
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有