ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:loadbalancer:mysql_replication:creating_connections

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
v5:loadbalancer:mysql_replication:creating_connections [2017/04/21 11:50] – external edit 127.0.0.1v5:loadbalancer:mysql_replication:creating_connections [2017/04/28 02:09] (current) mnewnham
Line 13: Line 13:
 |                                                             | Repeat for available number of secondary servers                                              | |                                                             | Repeat for available number of secondary servers                                              |
 | Execute commands against connection $db                     | Execute commands against connection pool $db                                                  | | Execute commands against connection $db                     | Execute commands against connection pool $db                                                  |
 +
 +We show that here, first by creating a normal connection, using a MySQL database
 +<code php>
 +$db = newAdoConnection('mysqli');
 +$db->connect('host','user','pass','database');
 +$db->execute('select * from employees');
 +</code>
 +If we create a load balanced connection, but only assign one server, the method is exactly the same
 +<code php>
 +$db = new ADOdbLoadBalancer;
 +
 +$db0 = new ADOdbLoadBalancerConnection('write',1,'host','user','pass','database');
 +$db->addConnection($db0);
 +
 +$db->execute('select * from employees')
 +</code>
 +
 +Note that because we have not assigned any ''readonly'' nodes, the ''write'' node assumes the responsibility
v5/loadbalancer/mysql_replication/creating_connections.1492768208.txt.gz · Last modified: 2017/04/28 02:09 (external edit)