Skip to content

Instantly share code, notes, and snippets.

@web-hat
Last active March 30, 2017 05:05
Show Gist options
  • Save web-hat/3660b0900e4674be3318990884620021 to your computer and use it in GitHub Desktop.
Save web-hat/3660b0900e4674be3318990884620021 to your computer and use it in GitHub Desktop.
Change Default Database connection Dynamically.
<?php
return [
//...
//...
'default' => 'mysql_primary',
'connections' => [
//..
//Our Default Database Connection
'mysql_primary' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'my_first_db',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
//Our Secondary Database Connection
'mysql_second' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'my_second_db',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
//..
//...
],
//..
//...
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment