Oracle 5.0 Reference Manual page 2669

Table of Contents

Advertisement

$ret = mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_SESSION);
if (!$ret)
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
/* Will use master and return fresh data, client can see his last write */
if (!$res = $mysqli->query("SELECT item, price FROM orders WHERE order_id = 1"))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
/* Back to default: use of all slaves and masters permitted, stale data can happen */
if (!mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
?>
See Also
mysqlnd_ms_get_last_gtid
Service level and consistency concept
Filter concept
20.7.6.8.7.
mysqlnd_ms_set_user_pick_server
Copyright 1997-2012 the PHP Documentation Group. [2230]
mysqlnd_ms_set_user_pick_server
Sets a callback for user-defined read/write splitting
Description
bool mysqlnd_ms_set_user_pick_server(
string function);
Sets a callback for user-defined read/write splitting. The plugin will call the callback only if
pick[]=user
file.
The plugins built-in read/write query split mechanism decisions can be overwritten in two ways. The
easiest way is to prepend the query string with the SQL hints
MYSQLND_MS_SLAVE_SWITCH
control, for example, whether a query shall be send to the MySQL replication master server or one
of the slave servers. By help of SQL hints it is not possible to pick a certain slave server for query
execution.
Full control on server selection can be gained using a callback function. Use of a callback is
recommended to expert users only because the callback has to cover all cases otherwise handled by
the plugin.
The plugin will invoke the callback function for selecting a server from the lists of configured master and
slave servers. The callback function inspects the query to run and picks a server for query execution by
returning the hosts URI, as found in the master and slave list.
If the lazy connections are enabled and the callback chooses a slave server for which no connection
has been established so far and establishing the connection to the slave fails, the plugin will return
an error upon the next action on the failed connection, for example, when running a query. It is the
responsibility of the application developer to handle the error. For example, the application can re-
run the query to trigger a new server selection and callback invocation. If so, the callback must make
sure to select a different slave, or check slave availability, before returning to the plugin to prevent an
endless loop.
Parameters
function
Mysqlnd replication and load balancing plugin (mysqlnd_ms)
is the default rule for server picking in the relevant section of the plugins configuration
or
MYSQLND_MS_LAST_USED_SWITCH
The function to be called. Class methods may also be invoked
statically using this function by passing
MYSQLND_MS_MASTER_SWITCH
2649
,
. Using SQL hints one can
array($classname,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents