config.php增加
'db2' => [
'type' => Env::get('DB_TYPE', 'mysql'),
'hostname' => Env::get('DB_HOST', '127.0.0.1'),
'database' => Env::get('DB_DATABASE', 'database_name'),
'username' => Env::get('DB_USERNAME', 'test'),
'password' => Env::get('DB_PASSWORD', 'test111'),
'hostport' => Env::get('DB_PORT', '3306'),
'charset' => Env::get('DB_CHARSET', 'utf8'),
'prefix' => Env::get('DB_PREFIX', 'de_'),
],
或者
'db2'=>require_once('database2.php'),
模型中
public function __construct($data = [])
{
$osDb = Config::get('os_db');
$this->connection = $osDb;
parent::__construct($data);
}
网友评论