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