Oracle 5.0 Reference Manual page 2648

Table of Contents

Advertisement

20.7.6.6.5. Plugin configuration file (<= 1.0.x)
Copyright 1997-2012 the PHP Documentation Group. [2230]
The plugin is using its own configuration file. The configuration file holds information on the MySQL
replication master server, the MySQL replication slave servers, the server pick (load balancing) policy,
the failover strategy and the use of lazy connections.
The PHP configuration directive
The configuration file mimics standard the
section defines its own unit of settings. There is no global section for setting defaults.
Applications reference sections by their name. Applications use section names as the host (server)
parameter to the various connect methods of the mysqli,
Mysqlnd replication and load balancing plugin (mysqlnd_ms)
Example 20.291. No automatic failover, error handling pitfall
<?php
/* assumption: automatic failover configured */
$mysqli = new mysqli("myapp", "username", "password", "database");
/* sets plugin internal state in_trx = 1 */
$mysqli->autocommit(false);
/* assumption: server fails */
if (!($res = $mysqli->query("SELECT 'Assume this query fails' AS _msg FROM
/* handle failure of transaction, plugin internal state is still in_trx =
printf("[%d] %s", $mysqli->errno, $mysqli->error);
/*
If using autocommit() based transaction detection it is a
MUST to call autocommit(true). Otherwise the plugin assumes
the current transaction continues and connection
changes remain forbidden.
*/
$mysqli->autocommit(true);
/* Likewise, you'll want to start a new transaction */
$mysqli->autocommit(false);
}
/* latin1 used from now on */
$mysqli->set_charset("latin1");
?>
If a server fails in the middle of a transaction the plugin continues
to refuse to switch connections until the current transaction has
been finished. Recall that the plugin monitors API calls to detect
transaction boundaries. Thus, you have to, for example, enable
auto commit mode to end the current transaction before the plugin
continues load balancing and switches the server. Likewise, you will
want to start a new transaction immediately thereafter and disable
auto commit mode again.
Not handling failed queries and not ending a failed transaction using
API calls may cause all following commands emit errors such as
Commands out of sync; you can't run this command
now. Thus, it is important to handle all errors.
Note
The below description applies to PECL/mysqlnd_ms < 1.1.0-beta. It is not valid
for later versions.
mysqlnd_ms.ini_file
is used to set the plugins configuration file.
format. It consists of one or more sections. Every
php.ini
mysql
and
2628
PDO_MYSQL
extensions.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents