ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:loadbalancer:adodbloadbalancerconnection

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:reference:loadbalancer:adodbloadbalancerconnection [2017/04/18 03:08] mnewnhamv5:reference:loadbalancer:adodbloadbalancerconnection [2017/04/27 01:07] (current) – [Other Parameters] mnewnham
Line 3: Line 3:
 <WRAP right box> <WRAP right box>
 == Applies To == == Applies To ==
-ADOdb Load Balancer+[[v5:loadbalancer:index|ADOdb Load Balancer]]
 == See Also == == See Also ==
-[[v5:reference:loadbalancer:getadodbobject|getADODbObject()]]\\ 
 [[v5:reference:loadbalancer:addconnection|addConnection()]] [[v5:reference:loadbalancer:addconnection|addConnection()]]
 == Syntax == == Syntax ==
Line 20: Line 19:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-The class ''ADOdbLoadBalancerConnection'' is the replacement for [[v5:reference:connection:adonewconnection|adoNewConnecton()]] and instantiates an ADOdb connection that can be retrieved and added to the connection pool. +The class ''ADOdbLoadBalancerConnection'' is the replacement for [[v5:reference:connection:adonewconnection|adoNewConnecton()]] and creates a template ADOdb connection that can be retrieved and added to the connection pool. 
 + 
 +Note that a connection is not established when the class is instantiated, it is delayed until an ADOdb command such as //**execute**// is issued, or a Load Balancer internal command such as [[v5:reference:loadbalancer:clusterexecute|clusterExecute()]] is issued. This means that a connection number is consumed even if the connection parameters are invalid. Care should be taken when using commands such as [[v5:reference:loadbalancer:removeconnection|removeConnection()]] that rely on a connection number. 
 ------------------------ ------------------------
 ===== Parameters ===== ===== Parameters =====
 ==== $driverName ==== ==== $driverName ====
-The name of the ADOdb driver to be used to  establish the connection. Currently only the drivers [[v5:database:mysql|mysqli]] and [[v5:database:postgres|postgres9]] can be used.+The name of the ADOdb driver to be used to  establish the connection. Currently only the drivers [[v5:database:mysql|mysqli]] and [[v5:database:postgresql|postgres9]] can be used.
 ==== $connectionType ==== ==== $connectionType ====
-A connection may be of the type ''write'', which designates the primary server through which all update operations are passed, and ''readonly'' , which signifies a secondary server through which all read-only operations are passed. Only one ''write'' connection can be designated, but there is no limit to the number of ''readonly'' connections.+A connection may be of the type ''write'', which designates the primary server through which all update operations are passed, and ''readonly'' , which signifies a secondary server through which some or all of the read-only operations are passed. Only one ''write'' connection can be designated, but there is no limit to the number of ''readonly'' connections.
 ==== $connectionWeight ==== ==== $connectionWeight ====
 For ''readonly'' connections, specifying a weight for the connection will influence how many queries are routed through a specific server. The higher the weight, the more often the server is used. If all ''readonly'' servers are defined with the same weight, then a connection randomiser effect is obtained. For ''readonly'' connections, specifying a weight for the connection will influence how many queries are routed through a specific server. The higher the weight, the more often the server is used. If all ''readonly'' servers are defined with the same weight, then a connection randomiser effect is obtained.
  
 ==== $persistantConnection ==== ==== $persistantConnection ====
 +This parameter forces the ADOdb connection to be made with a [[v5:reference:connection:pconnect|persistant]] connection.
 ==== Other Parameters ==== ==== Other Parameters ====
-The other parameters are defind the same as the equivalent connection parameters in ADOdb .+The other parameters are defined the same as the equivalent connection parameters in ADOdb . For more information, see the [[v5:reference:connection:connect|connect()]] command
 --------------------------- ---------------------------
 ===== Usage ==== ===== Usage ====
 <code php> <code php>
-$driver = 'mysqli'; 
-$db = new ADOdbLoadBalancer( $driver ); 
  
 +$db = new ADOdbLoadBalancer;
 +
 +$driver = 'mysqli';
 $database = 'employees'; $database = 'employees';
 $user     = 'adodb'; $user     = 'adodb';
Line 53: Line 56:
   $password,    $password, 
   $database );   $database );
-$db0->getADODbObject();+
 $db->addConnection( $db0 ); $db->addConnection( $db0 );
  
Line 66: Line 69:
   $password,    $password, 
   $database );   $database );
-$db1->getADODbObject();+
 $db->addConnection( $db1 ); $db->addConnection( $db1 );
  
Line 79: Line 82:
   $password,    $password, 
   $database );   $database );
-$db2->getADODbObject(); 
 $db->addConnection( $db2 ); $db->addConnection( $db2 );
  
 </code> </code>
  
v5/reference/loadbalancer/adodbloadbalancerconnection.1492477680.txt.gz · Last modified: 2017/04/21 11:37 (external edit)