zoukankan      html  css  js  c++  java
  • Discuz DB层跨库映射关系表名前缀BUG修复后产生的新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

  • 相关阅读:
    sendmessage参数
    combobox添加选项
    sql数据库时间转换convert
    Javascript知识四(DOM)
    Javascript知识三
    JavaScript知识(二)
    JavaScript知识(一)
    三层架构
    ADO知识的运用二(Day 28)
    SQL知识三(Day 27)
  • 原文地址:https://www.cnblogs.com/x3d/p/3916198.html
Copyright © 2011-2022 走看看