Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mysqlnd_uh_set_connection_proxy(3) [php man page]

MYSQLND_UH_SET_CONNECTION_PROXY(3)					 1					MYSQLND_UH_SET_CONNECTION_PROXY(3)

mysqlnd_uh_set_connection_proxy - Installs a proxy for mysqlnd connections

SYNOPSIS
bool mysqlnd_uh_set_connection_proxy (MysqlndUhConnection &$connection_proxy, [mysqli &$mysqli_connection]) DESCRIPTION
Installs a proxy object to hook mysqlnd's connection objects methods. Once installed, the proxy will be used for all MySQL connections opened with mysqli, mysql or PDO_MYSQL, assuming that the listed extensions are compiled to use the mysqlnd library. The function can be disabled with mysqlnd_uh.enable. If mysqlnd_uh.enable is set to FALSE the function will not install the proxy and always return TRUE. Additionally, an error of the type E_WARNING may be emitted. The error message may read like 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 [...]. PARAMETERS
o $connection_proxy - A proxy object of type MysqlndUhConnection. o $mysqli_connection - Object of type mysqli. If given, the proxy will be set for this particular connection only. RETURN VALUES
Returns TRUE on success. Otherwise, returns FALSE EXAMPLES
Example #1 mysqlnd_uh_set_connection_proxy(3) example <?php $mysqli = new mysqli("localhost", "root", "", "test"); $mysqli->query("SELECT 'No proxy installed, yet'"); class proxy extends MysqlndUhConnection { public function query($res, $query) { printf("%s(%s) ", __METHOD__, var_export(func_get_args(), true)); $ret = parent::query($res, $query); printf("%s returns %s ", __METHOD__, var_export($ret, true)); return $ret; } } mysqlnd_uh_set_connection_proxy(new proxy()); $mysqli->query("SELECT 'mysqlnd rocks!'"); $mysql = mysql_connect("localhost", "root", "", "test"); mysql_query("SELECT 'Ahoy Andrey!'", $mysql); $pdo = new PDO("mysql:host=localhost;dbname=test", "root", ""); $pdo->query("SELECT 'Moin Johannes!'"); ?> The above example will output: proxy::query(array ( 0 => NULL, 1 => 'SELECT 'mysqlnd rocks!'', )) proxy::query returns true proxy::query(array ( 0 => NULL, 1 => 'SELECT 'Ahoy Andrey!'', )) proxy::query returns true proxy::query(array ( 0 => NULL, 1 => 'SELECT 'Moin Johannes!'', )) proxy::query returns true SEE ALSO
mysqlnd_uh_set_statement_proxy(3), mysqlnd_uh.enable. PHP Documentation Group MYSQLND_UH_SET_CONNECTION_PROXY(3)

Check Out this Related Man Page

MYSQLND_QC_GET_QUERY_TRACE_LOG(3)					 1					 MYSQLND_QC_GET_QUERY_TRACE_LOG(3)

mysqlnd_qc_get_query_trace_log - Returns a backtrace for each query inspected by the query cache

SYNOPSIS
array mysqlnd_qc_get_query_trace_log (void ) DESCRIPTION
Returns a backtrace for each query inspected by the query cache. The collection of the backtrace is disabled by default. To collect the backtrace you have to set the PHP configuration directive mysqlnd_qc.collect_query_trace to 1 The maximum depth of the backtrace is limited to the depth set with the PHP configuration directive mysqlnd_qc.query_trace_bt_depth. PARAMETERS
This function has no parameters. RETURN VALUES
An array of query backtrace. Every list entry contains the query string, a backtrace and further detail information. +---------------------+---------------------------------------------------+ | Key | | | | | | | Description | | | | +---------------------+---------------------------------------------------+ | | | | query | | | | | | | Query string. | | | | | | | | origin | | | | | | | Code backtrace. | | | | | | | | run_time | | | | | | | Query run time in milliseconds. The collection | | | of all times and the necessary gettimeofday sys- | | | tem calls can be disabled by setting the PHP con- | | | figuration directive mysqlnd_qc.time_statistics | | | to 0 | | | | | | | | store_time | | | | | | | Query result set store time in milliseconds. The | | | collection of all times and the necessary get- | | | timeofday system calls can be disabled by setting | | | the PHP configuration directive | | | mysqlnd_qc.time_statistics to 0 | | | | | | | |eligible_for_caching | | | | | | | | | | TRUE if query is cacheable otherwise FALSE. | | | | | | | | no_table | | | | | | | | | | TRUE if the query has generated a result set and | | | at least one column from the result set has no | | | table name set in its metadata. This is usually | | | the case with queries which one probably do not | | | want to cache such as SELECT SLEEP(1). By default | | | any such query will not be added to the cache. | | | See also PHP configuration directive | | | mysqlnd_qc.cache_no_table. | | | | | | | | was_added | | | | | | | | | | TRUE if the query result has been put into the | | | cache, otherwise FALSE. | | | | | | | |was_already_in_cache | | | | | | | | | | TRUE if the query result would have been added to | | | the cache if it was not already in the cache | | | (cache hit). Otherwise FALSE. | | | | +---------------------+---------------------------------------------------+ EXAMPLES
Example #1 mysqlnd_qc_get_query_trace_log(3) example mysqlnd_qc.collect_query_trace=1 <?php /* Connect, create and populate test table */ $mysqli = new mysqli("host", "user", "password", "schema", "port", "socket"); $mysqli->query("DROP TABLE IF EXISTS test"); $mysqli->query("CREATE TABLE test(id INT)"); $mysqli->query("INSERT INTO test(id) VALUES(1), (2)"); /* not cached */ $res = $mysqli->query("SELECT id FROM test WHERE id = 1"); var_dump($res->fetch_assoc()); $res->free(); /* cache put */ $res = $mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/" . "SELECT id FROM test WHERE id = 2"); var_dump($res->fetch_assoc()); $res->free(); /* cache hit */ $res = $mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/" . "SELECT id FROM test WHERE id = 2"); var_dump($res->fetch_assoc()); $res->free(); var_dump(mysqlnd_qc_get_query_trace_log()); ?> The above examples will output: array(1) { ["id"]=> string(1) "1" } array(1) { ["id"]=> string(1) "2" } array(1) { ["id"]=> string(1) "2" } array(6) { [0]=> array(8) { ["query"]=> string(25) "DROP TABLE IF EXISTS test" ["origin"]=> string(102) "#0 qc.php(4): mysqli->query('DROP TABLE IF E...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(0) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [1]=> array(8) { ["query"]=> string(25) "CREATE TABLE test(id INT)" ["origin"]=> string(102) "#0 qc.php(5): mysqli->query('CREATE TABLE te...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(0) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [2]=> array(8) { ["query"]=> string(36) "INSERT INTO test(id) VALUES(1), (2)" ["origin"]=> string(102) "#0 qc.php(6): mysqli->query('INSERT INTO tes...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(0) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [3]=> array(8) { ["query"]=> string(32) "SELECT id FROM test WHERE id = 1" ["origin"]=> string(102) "#0 qc.php(9): mysqli->query('SELECT id FROM ...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(25) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [4]=> array(8) { ["query"]=> string(41) "/*qc=on*/SELECT id FROM test WHERE id = 2" ["origin"]=> string(103) "#0 qc.php(14): mysqli->query('/*qc=on*/SELECT...') #1 {main}" ["run_time"]=> int(311) ["store_time"]=> int(13) ["eligible_for_caching"]=> bool(true) ["no_table"]=> bool(false) ["was_added"]=> bool(true) ["was_already_in_cache"]=> bool(false) } [5]=> array(8) { ["query"]=> string(41) "/*qc=on*/SELECT id FROM test WHERE id = 2" ["origin"]=> string(103) "#0 qc.php(19): mysqli->query('/*qc=on*/SELECT...') #1 {main}" ["run_time"]=> int(13) ["store_time"]=> int(8) ["eligible_for_caching"]=> bool(true) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(true) } } SEE ALSO
Runtime configuration, mysqlnd_qc.collect_query_trace, mysqlnd_qc.query_trace_bt_depth, mysqlnd_qc.time_statistics, mysqlnd_qc.cache_no_ta- ble, mysqlnd_qc_get_normalized_query_trace_log(3). PHP Documentation Group MYSQLND_QC_GET_QUERY_TRACE_LOG(3)
Man Page