Mysqlnd user handler plugin (
mysqlnd_uh
)
2712
nothing but call their
mysqlnd
counterparts. By subclassing the classes you can install your own proxy
to monitor
mysqlnd
.
See also the
How it works
guide to learn about the inner workings of this extension.
Connection proxies are objects of the type
MysqlndUhConnection
. Connection proxy objects
are installed by
mysqlnd_uh_set_connection_proxy
. If you install the built-in class
MysqlndUhConnection
as a proxy, nothing happens. It behaves like a transparent proxy.
Example 20.332. Proxy registration, mysqlnd_uh.enable=1
<?php
mysqlnd_uh_set_connection_proxy(new MysqlndUhConnection());
$mysqli = new mysqli("localhost", "root", "", "test");
?>
The
PHP_INI_SYSTEM
configuration setting
mysqlnd_uh.enable
controls whether a proxy may be
set. If disabled, the extension will throw errors of type
E_WARNING
Example 20.333. Proxy installation disabled
mysqlnd_uh.enable=0
<?php
mysqlnd_uh_set_connection_proxy(new MysqlndUhConnection());
$mysqli = new mysqli("localhost", "root", "", "test");
?>
The above example will output:
PHP Warning: MysqlndUhConnection::__construct(): (Mysqlnd User Handler) The plugin has been disabled by setting the configuration parameter mysqlnd_uh.enabled = false. You must not use any of the base classes in %s on line %d
PHP Warning: mysqlnd_uh_set_connection_proxy(): (Mysqlnd User Handler) The plugin has been disabled by setting the configuration parameter mysqlnd_uh.enable = false. The proxy has not been installed in %s on line %d
To monitor
mysqlnd
, you have to write your own proxy object subclassing
MysqlndUhConnection
.
Please, see the function reference for a the list of methods that can be subclassed. Alternatively, you
can use reflection to inspect the built-in
MysqlndUhConnection
.
Create a new class
proxy
. Derive it from the built-in class
MysqlndUhConnection
. Replace the
MysqlndUhConnection::connect
. method. Print out the host parameter value passed to the
method. Make sure that you call the parent implementation of the
connect
method. Failing to do so
may give unexpected and undesired results, including memory leaks and crashes.
Register your proxy and open three connections using the PHP MySQL extensions
mysqli
,
mysql
,
PDO_MYSQL
. If the extensions have been compiled to use the
mysqlnd
library, the
proxy::connect
method will be called three times, once for each connection opened.
Example 20.334. Connection proxy
<?php
class proxy extends MysqlndUhConnection {
public function connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags) {
printf("Connection opened to '%s'\n", $host);
/* Always call the parent implementation! */
return parent::connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags);
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...