This article mainly introduced about the TP5 Project modification database, has certain reference value, now shares to everybody, has the need friend can refer to
-
Set model
<?phpnamespace app\home\model;use think\db;use think\model;class crddata extends model{protected $connection = [ //Database type ' type ' = ' mysql ', //Database connection DSN configuration ' dsn ' = ' = ', '// server address ' hostname ' = ' 127.0.0.1 ', //database name ' = ', '/ /database user name ' username ' = ' Root ', //Database password ' password ' = ' 123456 ', //Database connection Port ' hostport ' = ' 3306 ', Database connection Parameters ' params ' = [], //Database encoding defaults to UTF8 ' charset ' = ' utf8 ', //database table prefix ' prefix ' = ', ', ];}
2. The copy DB class is named Db1,
Edit database1 (Database configuration), root directory Extra
Usage and DB consistency