Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding instructions for master-slave connections

  • Loading branch information...
commit c9c2f4809261d7771c9542f8b612f1e9b99e4428 1 parent e2bdc95
@mariano authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 README.md
View
36 README.md
@@ -47,6 +47,42 @@ Connections::add('default', array(
));
```
+### Working with master-slave connections ###
+
+Thanks to Doctrine, master/slave connection queries can be done quite easy. All
+you have to do is slightly change your connection definition so you can use
+the `MasterSlaveConnection` wrapper class, and instead of simply specifying a
+single server, you give the details for the master server, and each of the
+slave servers. Example:
+
+```php
+Connections::add('default', array(
+ 'type' => 'Doctrine',
+ 'driver' => 'pdo_mysql',
+ 'wrapperClass' => 'Doctrine\DBAL\Connections\MasterSlaveConnection',
+ 'master' => array(
+ 'host' => 'master.example.com',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'dbname' => 'my_db'
+ ),
+ 'slaves' => array(
+ array(
+ 'host' => 'slave1.example.com',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'dbname' => 'my_db'
+ ),
+ array(
+ 'host' => 'slave2.example.com',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'dbname' => 'my_db'
+ )
+ )
+));
+```
+
## Working with models ##
### Creating models ###
Please sign in to comment.
Something went wrong with that request. Please try again.