Oracle 5.0 Reference Manual page 2731

Table of Contents

Advertisement

mysqlnd_uh will be called. The functions installed by PECL/mysqlnd_uh are the methods of the built-in
classes.
The built-in PHP classes and their methods do nothing but call their
behave exactly like the original
code what the extension does.
Example 20.330. Pseudo-code: what a built-in class does
class MysqlndUhConnection {
public function connect(($conn, $host, $user, $passwd, $db, $port, $socket, $mysql_flags) {
MYSQLND* c_mysqlnd_connection = convert_from_php_to_c($conn);
...
return call_c_function(mysqlnd_conn__connect(c_mysqlnd_connection, ...));
}
}
The build-in classes behave like a transparent proxy. It is possible for you to replace the proxy with
your own. This is done by subclassing
to extend the functionality of the proxy, followed by registering a new proxy object. Proxy objects are
installed by
mysqlnd_uh_set_connection_proxy
Example 20.331. Installing a proxy
<?php
class proxy extends MysqlndUhConnection {
public function connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags) {
printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
$ret = parent::connect($res, $host, $user, $passwd, $db, $port, $socket, $mysql_flags);
printf("%s returns %s\n", __METHOD__, var_export($ret, true));
return $ret;
}
}
mysqlnd_uh_set_connection_proxy(new proxy());
$mysqli = new mysqli("localhost", "root", "", "test");
?>
The above example will output:
proxy::connect(array (
0 => NULL,
1 => 'localhost',
2 => 'root',
3 => '',
4 => 'test',
5 => 3306,
6 => NULL,
7 => 131072,
))
proxy::connect returns true
20.7.8.4.3. Installing a proxy
Copyright 1997-2012 the PHP Documentation Group. [2230]
The extension provides two built-in classes:
MysqlndUhPreparedStatement. The classes are used for hooking
methods correspond to
Mysqlnd user handler plugin (mysqlnd_uh)
function they replace. The code below illustrates in pseudo-
mysqlnd
MysqlndUhConnection
MysqlndUhConnection
internal functions. By default they act like a transparent proxy and do
mysqlnd
2711
mysqlnd
or
MysqlndUhPreparedStatement
and mysqlnd_uh_set_statement_proxy.
and
mysqlnd
C library counterparts, to
library calls. Their

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents