class ConnectionManagerMasterSlave implements ConnectionManagerInterface
Manager for master/slave connection to a datasource.
Methods
setName(string $name) | ||
string | getName() | |
boolean |
isForceMasterConnection()
For replication, whether to always force the use of a master connection. |
|
setForceMasterConnection(boolean $isForceMasterConnection)
For replication, set whether to always force the use of a master connection. |
||
setWriteConfiguration(array $configuration)
Set the configuration for the master (write) connection. |
||
setReadConfiguration(array $configuration)
Set the configuration for the slave (read) connections. |
||
ConnectionInterface |
getWriteConnection(AdapterInterface $adapter = null)
Get a master connection. |
|
ConnectionInterface |
getReadConnection(AdapterInterface $adapter = null)
Get a slave connection. |
|
closeConnections() |
Details
at line 53
public
setName(string $name)
at line 61
public string
getName()
at line 71
public boolean
isForceMasterConnection()
For replication, whether to always force the use of a master connection.
at line 81
public
setForceMasterConnection(boolean $isForceMasterConnection)
For replication, set whether to always force the use of a master connection.
at line 99
public
setWriteConfiguration(array $configuration)
Set the configuration for the master (write) connection.
<code>
$manager->setWriteConfiguration(array(
'dsn' => 'mysql:dbname=test_master',
'user' => 'mywriteuser',
'password' => 'S3cr3t'
));
</code>
at line 125
public
setReadConfiguration(array $configuration)
Set the configuration for the slave (read) connections.
<code>
$manager->setReadConfiguration(array(
array(
'dsn' => 'mysql:dbname=test_slave1',
'user' => 'myreaduser',
'password' => 'F00baR'
),
array(
'dsn' => 'mysql:dbname=test_slave2',
'user' => 'myreaduser',
'password' => 'F00baR'
)
));
</code>
at line 140
public ConnectionInterface
getWriteConnection(AdapterInterface $adapter = null)
Get a master connection.
If no master connection exist yet, open it using the write configuration.
at line 160
public ConnectionInterface
getReadConnection(AdapterInterface $adapter = null)
Get a slave connection.
If no slave connection exist yet, choose one configuration randomly in the
read configuration to open it.