ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:loadbalancer:clusterexecute

clusterExecute

Applies To

ADOdb Load Balancer

Syntax
mixed clusterExecute(
  string $sql,
  optional bool $inputArray = false,
  optional bool $returnAllResults = false,
  optional bool $existingConnectionsOnly = true
)

Description

The method clusterExecute() is used to simultaneously execute an SQL statement across all nodes in the load balancing group. It is primarily used for setting Server parameters.


Parameters

The first two parameters follow the rules as specified in the ADOdb execute() command.

$returnAllResults

The default behavior of the command is to return the result of the execution of the command from first connected server in the pool. If the parameter is set to true, then the results of all executions are collected into an array and returned ordered by connection.

/*
* Connection pool with 3 MySQL servers
*/
$a = $db->clusterExecute('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
                         false,
                         false,
                         false);
print_r($a);
/*
* Returns
Array
(
    [0] => ADORecordSet_empty Object
        (
            [dataProvider] => empty
            [databaseType] => 
            [EOF] => 1
            [_numOfRows] => 0
            [fields] => 
            [connection] => 
        )
 
    [1] => ADORecordSet_empty Object
        (
            [dataProvider] => empty
            [databaseType] => 
            [EOF] => 1
            [_numOfRows] => 0
            [fields] => 
            [connection] => 
        )
 
    [2] => ADORecordSet_empty Object
        (
            [dataProvider] => empty
            [databaseType] => 
            [EOF] => 1
            [_numOfRows] => 0
            [fields] => 
            [connection] => 
        )
 
)
*/
 
$a = $db->clusterExecute('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
                         false,
                         true,
                         false);
print_r($a);
/*
* Returns
ADORecordSet_empty Object
(
    [dataProvider] => empty
    [databaseType] => 
    [EOF] => 1
    [_numOfRows] => 0
    [fields] => 
    [connection] => 
)
*/

$existingConnectionsOnly

If the existingConnectionsOnly flag is set to true, the command passed to clusterExecute will only be executed against connections that are already in use, otherwise, the clusterExecute command will establish a connection to the database and then execute the command.

v5/reference/loadbalancer/clusterexecute.txt · Last modified: 2017/04/25 01:11 by mnewnham