当前位置:网站首页>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
边栏推荐
- Position encoding practice in transformer
- 基于check-point实现图数据构建任务
- Object.keys()的用法
- Redis: SDS source code analysis
- Transformer中position encoding实践
- 51 single chip microcomputer temperature alarm based on WiFi control
- How to decrypt worksheet protection password in Excel file
- Analysis of abnormal frequency of minor GC in container environment
- Accounting regulations and professional ethics [8]
- Spark 中的 Rebalance 操作以及与Repartition操作的区别
猜你喜欢
Visual Studio 2019 (LocalDB)MSSQLLocalDB SQL Server 2014 数据库版本为852无法打开,此服务器支持782
go-micro教程 — 第二章 go-micro v3 使用Gin、Etcd
世界环境日 | 周大福用心服务推动减碳环保
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Go micro tutorial - Chapter 2 go micro V3 using gin and etcd
《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下
太方便了,钉钉上就可完成代码发布审批啦!
GO开发:如何利用Go单例模式保障流媒体高并发的安全性?
从数数开始
Object.keys()的用法
随机推荐
安信证券手机版下载 网上开户安全吗
程序员怎么才能提高代码编写速度?
[acwing] 58 weeks 4489 Longest subsequence
Hash table
表单传递时,如何隐式将值传过去
GO开发:如何利用Go单例模式保障流媒体高并发的安全性?
C # realizes FFT forward and inverse transformation and frequency domain filtering
Accounting regulations and professional ethics [7]
Research Report on market supply and demand and strategy of China's well completion equipment industry
Firebird experience summary
Years of training, towards Kata 3.0! Enter the safe container experience out of the box | dragon lizard Technology
Market trend report, technical innovation and market forecast of taillight components in China
Array filter fliter in JS
手里10万元存款买什么理财产品收益最高?
Integration of ongdb graph database and spark
Accounting regulations and professional ethics [10]
Is it safe for Anxin securities to open an account online? Is the account opening fee charged
The Ministry of human resources and Social Security announced the new construction occupation
APOC自定义函数和过程
FIREBIRD使用经验总结