Oracle 5.0 Reference Manual page 2670

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
Return Values
Host to run the query on. The host URI is to be taken from the master and slave connection lists
passed to the callback function. If callback returns a value neither found in the master nor in the slave
connection lists the plugin will fallback to the second pick method configured via the
in the plugin configuration file. If not second pick method is given, the plugin falls back to the build-in
default pick method for server selection.
Notes
Note
mysqlnd_ms_set_user_pick_server
< 1.1.0. It has been replaced by the
History
Examples
Example 20.303.
mysqlnd_ms_set_user_pick_server
[myapp]
master[] = localhost
slave[] = 192.168.2.27:3306
slave[] = 192.168.78.136:3306
pick[] = user
<?php
function pick_server($connected, $query, $master, $slaves, $last_used)
{
static $slave_idx = 0;
static $num_slaves = NULL;
if (is_null($num_slaves))
$num_slaves = count($slaves);
/* default: fallback to the plugins build-in logic */
$ret = NULL;
printf("User has connected to '%s'...\n", $connected);
printf("... deciding where to run '%s'\n", $query);
$where = mysqlnd_ms_query_is_select($query);
switch ($where)
{
case MYSQLND_MS_QUERY_USE_MASTER:
printf("... using master\n");
$ret = $master[0];
break;
case MYSQLND_MS_QUERY_USE_SLAVE:
/* SELECT or SQL hint for using slave */
if (stristr($query, "FROM table_on_slave_a_only"))
{
/* a table which is only on the first configured slave
printf("... access to table available only on slave A detected\n");
$ret = $slaves[0];
}
else
{
/* round robin */
printf("... some read-only query for a slave\n");
$methodname)
methods of an object instance may be called by passing
array($objectinstance, $methodname)
for upgrade notes.
2650
to this parameter. Additionally class
is available with PECL mysqlnd_ms
filter. Please, check the
user
example
*/
to this parameter.
setting
pick[]
Change

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents