Skip to content

Instantly share code, notes, and snippets.

@zdev0x
Last active April 8, 2018 07:30
Show Gist options
  • Select an option

  • Save zdev0x/0cc95b459e4a8df7873434b6ab5c6af3 to your computer and use it in GitHub Desktop.

Select an option

Save zdev0x/0cc95b459e4a8df7873434b6ab5c6af3 to your computer and use it in GitHub Desktop.
[Yii2 Database Master Slaves Config] #yii2
# filename: common/main-local.php
components => [
/**
* Master
*/
'db' => [
'class' => 'yii\db\Connection',
'charset' => 'utf8',
'dsn' => 'mysql:host=master.db.dev;dbname=yii2db',
'username' => 'yii2db',
'password' => 'yii2db',
'slaveConfig' => [
'username' => "yii2db_slave",
"password" => "yii2db_slave_pwd",
"attributes" => [
PDO::ATTR_TIMEOUT => 10,
]
],
/**
* Slaves
*/
'slaves' => [
['dsn' => 'mysql:host=slave1.db.dev;dbname=yii2db'],
['dsn' => 'mysql:host=slave2.db.dev;dbname=yii2db'],
['dsn' => 'mysql:host=slave3.db.dev;dbname=yii2db'],
],
],
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment