新的逻辑引入了新的bug,会导致在跨多库连接时,产生表名前缀映射混乱,需要再做逻辑上的修复。

 

Discuz DB层跨库映射关系表名前缀BUG修复后产生的新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

相关文章:

  • 2022-02-26
  • 2021-05-27
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2021-06-28
猜你喜欢
  • 2021-07-09
  • 2021-05-16
  • 2021-08-01
  • 2021-07-25
  • 2021-11-07
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案