当前位置:网站首页>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
边栏推荐
- Overflow: the combination of auto and Felx
- Principle and general steps of SQL injection
- Understand ThreadLocal in one picture
- 太方便了,钉钉上就可完成代码发布审批啦!
- Smart Logistics Park supply chain management system solution: digital intelligent supply chain enables a new supply chain model for the logistics transportation industry
- PyTorch深度学习快速入门教程
- S2b2b solution for lighting industry: efficiently enable the industrial supply chain and improve the economic benefits of enterprises
- Use and principle of thread pool
- [acwing] 58 weeks 4489 Longest subsequence
- Lv166 turned over
猜你喜欢
Why do you say that the maximum single table of MySQL database is 20million? Based on what?
overflow:auto与felx结合的用法
Object. Usage of keys()
go-micro教程 — 第二章 go-micro v3 使用Gin、Etcd
How to implement a delay queue?
Principle and general steps of SQL injection
矿产行业商业供应链协同系统解决方案:构建数智化供应链平台,保障矿产资源安全供应
电子元器件B2B商城系统开发:赋能企业构建进销存标准化流程实例
Understand asp Net core - Authentication Based on jwtbearer
从数数开始
随机推荐
力扣今日题-1200. 最小绝对差
Research Report on market supply and demand and strategy of China's four sided flat bag industry
线性时间排序
中位数与次序统计量
How to implement a delay queue?
tp配置多数据库
L1-072 scratch lottery
安信证券网上开户安全吗 开户收费吗
Market trend report, technical innovation and market forecast of taillight components in China
Solution of commercial supply chain coordination system in the mineral industry: build a digital intelligent supply chain platform to ensure the safe supply of mineral resources
Practice: fabric user certificate revocation operation process
Statistical learning: logistic regression and cross entropy loss (pytoch Implementation)
Solution du système de gestion de la chaîne d'approvisionnement du parc logistique intelligent
go-micro教程 — 第二章 go-micro v3 使用Gin、Etcd
基于wifi控制的51单片机温度报警器
Market trend report, technical innovation and market forecast of China's hair repair therapeutic apparatus
How can programmers improve the speed of code writing?
散列表
太方便了,钉钉上就可完成代码发布审批啦!
Unity interview questions (continuously updated)