zoukankan      html  css  js  c++  java
  • discuz多数据库

    disucz  多实例数据库 代码调用 。

    成功案例基于 discuz 2.5
    修改 conf/config_global.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    //新增数据库配置信息
      
    $_config['db']['2']['dbhost'] ='192.168.1.2';
    $_config['db']['2']['dbuser'] ='root';
    $_config['db']['2']['dbpw'] ='123';
    $_config['db']['2']['dbcharset'] ='utf8';
    $_config['db']['2']['pconnect'] ='0';
    $_config['db']['2']['dbname'] ='op';
    $_config['db']['2']['tablepre'] ='op_';

    修改 source/class/class_core.php

    1
    2
    //最下面一行 增加
    classDB_BIextendsdiscuz_database{}

    复制 soucrce/class/db_driver_mysql.php
    成 db_driver_mysql_bi.php

    修改 db_driver_mysql_bi.php 中

    1
    2
    3
    4
    5
    6
    //修改class名字
    classdb_driver_mysql_bi.php
    //修改读取配置文件的序列号
    $this->tablepre =$config['2']['tablepre'];
    //设置connect的标识信息
    functionconnect($serverid= 2) {

    引用新的数据库代码操作实例

    1
    2
    3
    4
    5
    6
    7
    $driver='db_driver_mysql_op';
    $_config=array();
    @includeDISCUZ_ROOT.'./config/config_global.php';
    DB_BI::init($driver,$_config['db']);
      
    $userinfo= DB_BI::fetch_first("SELECT * FROM op_users");
    var_dump($userinfo);
  • 相关阅读:
    [WC2010]重建计划
    [POJ1741]Tree
    [NOI2008]志愿者招募
    [BZOJ2127]happiness
    「网络流 24 题」太空飞行计划
    [TJOI2015]线性代数
    [HDU2874]Connections between cities
    [POI2007]ZAP-Queries
    [SCOI2010]幸运数字
    POJ 2826 An Easy Problem?!
  • 原文地址:https://www.cnblogs.com/fenle/p/4395467.html
Copyright © 2011-2022 走看看