当前位置:网站首页>TP configuring multiple databases
TP configuring multiple databases
2022-07-04 17:04:00 【wiscourper_】
1、 stay database.php Add
'db2' => [
// Database type
'type' => 'mysql',
// Server address
'hostname' => '127.0.0.1',
// Database name
'database' => 'test',
// user name
'username' => 'root',
// password
'password' => 'root',
// port
'hostport' => '3306',
// Connect dsn
'dsn' => '',
// Database connection parameters
'params' => [],
// The database encoding defaults to utf8
'charset' => 'utf8',
// Database table prefix
'prefix' => 'tn_',
// Database debugging mode
'debug' => true,
// Database deployment :0 Centralized ( Single server ),1 Distributed ( Master slave server )
'deploy' => 0,
// Is the database read-write separated Master slave is effective
'rw_separate' => false,
// After the separation of reading and writing Number of primary servers
'master_num' => 1,
// Specify the slave server serial number
'slave_no' => '',
// Automatically read the main database data
'read_master' => false,
// Whether to strictly check whether the field exists
'fields_strict' => true,
// Dataset return type
'resultset_type' => 'array',
// Auto write timestamp field
'auto_timestamp' => false,
// The default time format after the time field is taken out
'datetime_format' => 'Y-m-d H:i:s',
// Is it necessary to SQL Performance analysis
'sql_explain' => false,
]
2、 The other set is the original one
3、 test
$db2 = \think\Db::connect(config('database.db2'));
$res = $db2->name("user")->find();
var_dump(\think\Db::table("customer")->find());// The original
var_dump($res);die;//db2 Of
边栏推荐
- Practice: fabric user certificate revocation operation process
- Can you really use MySQL explain?
- 中位数与次序统计量
- Market trend report, technical innovation and market forecast of taillight components in China
- Congratulations to Mr. Zhang Pengfei, chief data scientist of artefact, for winning the campaign Asia tech MVP 2022
- Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"
- APOC自定义函数和过程
- Unity interview questions (continuously updated)
- 时序图数据建模与产业链分析
- Sql实现Split
猜你喜欢
Readis configuration and optimization of NoSQL (final chapter)
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
昆明三环闭合工程将经过这些地方,有在你家附近的吗?
Overflow: the combination of auto and Felx
GO开发:如何利用Go单例模式保障流媒体高并发的安全性?
S2b2b solution for lighting industry: efficiently enable the industrial supply chain and improve the economic benefits of enterprises
Analysis of abnormal frequency of minor GC in container environment
Principle and general steps of SQL injection
智慧物流园区供应链管理系统解决方案:数智化供应链赋能物流运输行业供应链新模式
Years of training, towards Kata 3.0! Enter the safe container experience out of the box | dragon lizard Technology
随机推荐
散列表
力扣今日题-1200. 最小绝对差
Height residual method
2022PMP考试基本情况详情了解
Spark 中的 Rebalance 操作以及与Repartition操作的区别
昆明三环闭合工程将经过这些地方,有在你家附近的吗?
如何为ONgDB核心项目源码做贡献
Accounting regulations and professional ethics [10]
ECCV 2022放榜了:1629篇论文中选,录用率不到20%
Understand ThreadLocal in one picture
How to implement a delay queue?
Research Report on plastic recycling machine industry - market status analysis and development prospect forecast
高度剩余法
[glide] cache implementation - memory and disk cache
Visual Studio 2019 (LocalDB)MSSQLLocalDB SQL Server 2014 数据库版本为852无法打开,此服务器支持782
基于wifi控制的51单片机温度报警器
Yanwen logistics plans to be listed on Shenzhen Stock Exchange: it is mainly engaged in international express business, and its gross profit margin is far lower than the industry level
Oracle监听器Server端与Client端配置实例
Why do you say that the maximum single table of MySQL database is 20million? Based on what?
Market trend report, technical innovation and market forecast of tetrabromophthalate (pht4 diol) in China