thinkcmf链接多个数据库

 1、打开/data/conf/config.php

    'db1'=>[
        // 数据库类型
        'type'     => 'mysql',
        // 服务器地址
        'hostname' => '',
        // 数据库名
        'database' => '',
        // 用户名
        'username' => '',
        // 密码
        'password' => '',
        // 端口
        'hostport' => '3306',
        // 数据库编码默认采用utf8
        'charset'  => 'utf8mb4',
        // 数据库表前缀
        'prefix'   => 'cmf_',
        "authcode" => 'BadD4wbA22j1W2Y7vI',
    ]

   2、在需要用到的地方调用

db('表名','db1')->select();

  

posted @ 2019-10-18 11:36  小ྀ青ྀ年້  阅读(1020)  评论(0编辑  收藏  举报