Oracle 5.0 Reference Manual page 2733

Table of Contents

Advertisement

}
}
mysqlnd_uh_set_connection_proxy(new proxy());
$mysqli = new mysqli("localhost", "root", "", "test");
$mysql = mysql_connect("localhost", "root", "");
$pdo = new PDO("mysql:host=localhost;dbname=test", "root", "");
?>
The above example will output:
Connection opened to 'localhost'
Connection opened to 'localhost'
Connection opened to 'localhost'
The use of prepared statement proxies follows the same pattern: create a proxy
object of the type
mysqlnd_uh_set_statement_proxy.
Example 20.335. Prepared statement proxy
<?php
class stmt_proxy extends MysqlndUhPreparedStatement {
public function prepare($res, $query) {
printf("%s(%s)\n", __METHOD__, $query);
return parent::prepare($res, $query);
}
}
mysqlnd_uh_set_statement_proxy(new stmt_proxy());
$mysqli = new mysqli("localhost", "root", "", "test");
$stmt = $mysqli->prepare("SELECT 'mysqlnd hacking made easy' AS _msg FROM DUAL");
?>
The above example will output:
stmt_proxy::prepare(SELECT 'mysqlnd hacking made easy' AS _msg FROM DUAL)
20.7.8.4.4. Basic query monitoring
Copyright 1997-2012 the PHP Documentation Group. [2230]
Basic monitoring of a query statement is easy with PECL/mysqlnd_uh. Combined with
debug_print_backtrace
statement. This may be desired when searching for slow queries but also after database refactoring to
find code still accessing deprecated databases or tables. The latter may be a complicated matter to do
otherwise, especially if the application uses auto-generated queries.
Example 20.336. Basic Monitoring
<?php
class conn_proxy extends MysqlndUhConnection {
public function query($res, $query) {
debug_print_backtrace();
return parent::query($res, $query);
}
}
Mysqlnd user handler plugin (mysqlnd_uh)
MysqlndUhPreparedStatement
it can become a powerful tool, for example, to find the origin of certain
and install the proxy using
2713

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents