Skip to content

Instantly share code, notes, and snippets.

@serefercelik
Created March 14, 2020 16:18
Show Gist options
  • Save serefercelik/9dadc94c7579a7ad37e987341a59b3f4 to your computer and use it in GitHub Desktop.
Save serefercelik/9dadc94c7579a7ad37e987341a59b3f4 to your computer and use it in GitHub Desktop.
// Before returning the database configuration, place read hosts into an array.
$readHosts = ['193.168.1.1', '194.168.1.1'];
//
'mysql' => array(
'read' => array(
// Return a random host
'host' => $readHosts[array_rand($readHosts)],
),
'write' => array(
'host' => '196.168.1.2'
),
'driver' => 'mysql',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment