1.设置model
<?php
namespace app\home\model;
use think\Db;
use think\Model;
class Crddata extends Model
{
protected $connection = [
// 数据库类型
'type' => 'mysql',
// 数据库连接DSN配置
'dsn' => '',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => '',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => '123456',
// 数据库连接端口
'hostport' => '3306',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => '',
];
}
2.复制Db类命名为Db1,
编辑database1(数据库配置)->根目录extra下
用法和Db一致