Mysqlnd user handler plugin (
mysqlnd_uh
)
2714
class stmt_proxy extends MysqlndUhPreparedStatement {
public function prepare($res, $query) {
debug_print_backtrace();
return parent::prepare($res, $query);
}
}
mysqlnd_uh_set_connection_proxy(new conn_proxy());
mysqlnd_uh_set_statement_proxy(new stmt_proxy());
printf("Proxies installed...\n");
$pdo = new PDO("mysql:host=localhost;dbname=test", "root", "");
var_dump($pdo->query("SELECT 1 AS _one FROM DUAL")->fetchAll(PDO::FETCH_ASSOC));
$mysqli = new mysqli("localhost", "root", "", "test");
$mysqli->prepare("SELECT 1 AS _two FROM DUAL");
?>
The above example will output:
#0 conn_proxy->query(Resource id #19, SELECT 1 AS _one FROM DUAL)
#1 PDO->query(SELECT 1 AS _one FROM DUAL) called at [example.php:19]
array(1) {
[0]=>
array(1) {
["_one"]=>
string(1) "1"
}
}
#0 stmt_proxy->prepare(Resource id #753, SELECT 1 AS _two FROM DUAL)
#1 mysqli->prepare(SELECT 1 AS _two FROM DUAL) called at [example.php:22]
For basic query monitoring you should install a connection and a prepared statement proxy. The
connection proxy should subclass
MysqlndUhConnection::query
. All database queries not using
native prepared statements will call this method. In the example the
query
function is invoked by a
PDO call. By default,
PDO_MySQL
is using prepared statement emulation.
All native prepared statements are prepared with the
prepare
method of
mysqlnd
exported through
MysqlndUhPreparedStatement::prepare
. Subclass
MysqlndUhPreparedStatement
and
overwrite
prepare
for native prepared statement monitoring.
20.7.8.5. Installing/Configuring
Copyright 1997-2012 the PHP Documentation Group. [2230]
20.7.8.5.1. Requirements
Copyright 1997-2012 the PHP Documentation Group. [2230]
PHP 5.3.3
or later. It is recommended to use
PHP 5.4.0
or later to get access to the latest mysqlnd
features.
The
mysqlnd_uh
user handler plugin supports all PHP applications and all available PHP MySQL
extensions (
mysqli
,
mysql
,
PDO_MYSQL
). The PHP MySQL extension must be configured to use
mysqlnd
in order to be able to use the
mysqlnd_uh
plugin for
mysqlnd
.
The alpha versions makes use of some
mysqli
features. You must enable
mysqli
to compile the plugin.
This requirement may be removed in the future. Note, that this requirement does not restrict you to use
the plugin only with
mysqli
. You can use the plugin to monitor
mysql
,
mysqli
and
PDO_MYSQL
.
20.7.8.5.2. Installation
Copyright 1997-2012 the PHP Documentation Group. [2230]
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 ...