This article mainly introduces the modification of the Tp5 project database, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
Setting 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. Copy the Db class and name it Db1,
Edit database1 (database Configuration) ->Under the root directory extra
The usage is consistent with Db
Related recommendations:
tp5 operation mongoDB database instance
TP5 Auth permission management example
The above is the detailed content of Tp5 project modification database. For more information, please follow other related articles on the PHP Chinese website!