新的逻辑引入了新的bug,会导致在跨多库连接时,产生表名前缀映射混乱,需要再做逻辑上的修复。
function table_name($tablename) { if(!empty($this->map) && !empty($this->map[$tablename])) { $id = $this->map[$tablename]; if(!empty($this->config[$id]['tablePRe'])){ $this->tablepre = $this->config[$id]['tablepre']; } if(!$this->link[$id]) { $this->connect($id); } $this->curlink = $this->link[$id]; } else { $this->tablepre = $this->config['1']['tablepre']; $this->curlink = $this->link[1]; } return $this->tablepre.$tablename; }
附db Map 写法:
$_config['db']['1']['dbhost'] = 'localhost'; // 服务器地址$_config['db']['1']['dbuser'] = 'root'; // 用户$_config['db']['1']['dbpw'] = 'root';// 密码$_config['db']['1']['dbcharset'] = 'gbk';// 字符集$_config['db']['1']['pconnect'] = '0';// 是否持续连接$_config['db']['1']['dbname'] = 'x1';// 数据库$_config['db']['1']['tablepre'] = 'pre_';// 表名前缀$_config['db']['2']['dbhost'] = 'localhost';.....//再配置一些数据源$_config['db']['xxx_sys']['dbhost'] = 'localhost';//映射$_config['db']['map']['yyy_table'] = 'xxx_sys';
上一篇文章:http://www.cnblogs.com/x3d/p/3913690.html