当主数据库由于某些原因无法连接时,你可以配置多个灾备数据库。
例如可以像下面这样为一个连接配置灾备数据库:
config/database.php
'127.0.0.1', 'username' => 'demo8', 'password' => 'demo8', 'database' => 'demo8', 'DBPrefix' => 'dr_', ]; // 备用库 $db['failover'] = [ [ 'hostname' => '127.0.0.122', 'username' => 'demo8', 'password' => 'demo8', 'database' => 'demo8', ], [ 'hostname' => '127.0.0.133', 'username' => 'demo8', 'password' => 'demo8', 'database' => 'demo8', ] ];