1--TEST-- 2mysqli_debug() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8 9if (!function_exists('mysqli_debug')) 10 die("skip: mysqli_debug() not available"); 11 12if (!defined('MYSQLI_DEBUG_TRACE_ENABLED')) 13 die("skip: can't say for sure if mysqli_debug works"); 14 15if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) 16 die("skip: debug functionality not enabled"); 17?> 18--FILE-- 19<?php 20 require_once('connect.inc'); 21 22 // NOTE: documentation is not clear on this: function always return NULL or TRUE 23 if (true !== ($tmp = mysqli_debug(sprintf('d:t:O,%s/mysqli_debug_phpt.trace', sys_get_temp_dir())))) 24 printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 25 26 if ($IS_MYSQLND) { 27 // let's make this mysqlnd only - for libmysql we need debug installation 28 29 // table.inc will create a database connection and run some SQL queries, therefore 30 // the debug file should have entries 31 require_once('table.inc'); 32 33 clearstatcache(); 34 $trace_file = sprintf('%s/mysqli_debug_phpt.trace', sys_get_temp_dir()); 35 if (!file_exists($trace_file)) 36 printf("[003] Trace file '%s' has not been created\n", $trace_file); 37 if (filesize($trace_file) < 50) 38 printf("[004] Trace file '%s' is very small. filesize() reports only %d bytes. Please check.\n", 39 $trace_file, 40 filesize($trace_file)); 41 42 // will mysqli_debug() mind if the trace file gets removed? 43 unlink($trace_file); 44 clearstatcache(); 45 46 if (!$res = mysqli_query($link, 'SELECT * FROM test')) 47 printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 48 else 49 mysqli_free_result($res); 50 51 mysqli_close($link); 52 53 clearstatcache(); 54 if (!file_exists($trace_file)) 55 printf("[006] Trace file '%s' does not exist\n", $trace_file); 56 unlink($trace_file); 57 } 58 59 print "done!"; 60?> 61--CLEAN-- 62<?php 63 require_once("clean_table.inc"); 64?> 65--EXPECTF-- 66done%s 67