Tp5 project modification database

不言
Release: 2023-03-25 09:12:01
Original
4147 people have browsed it

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

  1. Setting model

<?php
namespace app\home\model;
use think\Db;

use think\Model;

class Crddata extends Model
{
	protected $connection = [  
        // 数据库类型  
        &#39;type&#39;        => &#39;mysql&#39;,  
        // 数据库连接DSN配置  
        &#39;dsn&#39;         => &#39;&#39;,  
        // 服务器地址  
        &#39;hostname&#39;    => &#39;127.0.0.1&#39;,  
        // 数据库名  
        &#39;database&#39;    => &#39;&#39;,  
        // 数据库用户名  
        &#39;username&#39;    => &#39;root&#39;,  
        // 数据库密码  
        &#39;password&#39;    => &#39;123456&#39;,  
        // 数据库连接端口  
        &#39;hostport&#39;    => &#39;3306&#39;,  
        // 数据库连接参数  
        &#39;params&#39;      => [],  
        // 数据库编码默认采用utf8  
        &#39;charset&#39;     => &#39;utf8&#39;,  
        // 数据库表前缀  
        &#39;prefix&#39;      => &#39;&#39;,  
    ]; 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!