1--TEST-- 2mysqli_get_client_stats() - skipped rows 3--INI-- 4mysqlnd.collect_statistics="1" 5mysqlnd.collect_memory_statistics="1" 6--SKIPIF-- 7<?PHP 8require_once('skipif.inc'); 9require_once('skipifemb.inc'); 10require_once('skipifconnectfailure.inc'); 11if (!function_exists('mysqli_get_client_stats')) { 12 die("skip only available with mysqlnd"); 13} 14?> 15--FILE-- 16<?php 17 require_once('connect.inc'); 18 require_once('table.inc'); 19 20 if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_STORE_RESULT)) 21 printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 22 23 $num_rows = mysqli_num_rows($res); 24 assert($num_rows > 2); 25 mysqli_free_result($res); 26 27 $before = mysqli_get_client_stats(); 28 printf("BEFORE: rows_skipped_normal = %d\n", $before['rows_skipped_normal']); 29 30 if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) 31 printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 32 33 /* fetch all rows but the last one */ 34 for ($i = 0; $i < $num_rows - 1; $i++) 35 $row = mysqli_fetch_assoc($res); 36 37 /* enforce implicit cleaning of the wire and skipping the last row */ 38 mysqli_free_result($res); 39 $after = mysqli_get_client_stats(); 40 printf("AFTER: rows_skipped_normal = %d\n", $after['rows_skipped_normal']); 41 42 if ($after['rows_skipped_normal'] != $before['rows_skipped_normal'] + 1) 43 printf("Statistics should show an increase of 1 for rows_skipped_normal, ". 44 "but before=%d after=%d\n", $before['rows_skipped_normal'], $after['rows_skipped_normal']); 45 46 mysqli_close($link); 47 print "done!"; 48?> 49--EXPECTF-- 50BEFORE: rows_skipped_normal = %d 51AFTER: rows_skipped_normal = %d 52done! 53