PHP  
 PHP_5_6
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/mysqli/tests/mysqli_num_rows.phpt ('mysqli_num_rows()')

Script

1: <?php
2:     
require_once("connect.inc");
3:
4:     
$tmp    NULL;
5:     
$link   NULL;
6:
7:     if (!
is_null($tmp = @mysqli_num_rows()))
8:         
printf("[001] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
9:
10:     if (!
is_null($tmp = @mysqli_num_rows($link)))
11:         
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
12:
13:     require(
'table.inc');
14:
15:     function 
func_test_mysqli_num_rows($link$query$expected$offset$test_free false) {
16:
17:         if (!
$res mysqli_query($link$queryMYSQLI_STORE_RESULT)) {
18:             
printf("[%03d] [%d] %s\n"$offsetmysqli_errno($link), mysqli_error($link));
19:             return;
20:         }
21:
22:         if (
$expected !== ($tmp mysqli_num_rows($res)))
23:             
printf("[%03d] Expecting %s/%d, got %s/%d\n"$offset 1,
24:                 
gettype($expected), $expected,
25:                 
gettype($tmp), $tmp);
26:
27:         
mysqli_free_result($res);
28:
29:         if (
$test_free && (NULL !== ($tmp mysqli_num_rows($res))))
30:             
printf("[%03d] Expecting NULL, got %s/%s\n"$offset 2gettype($tmp), $tmp);
31:
32:     }
33:
34:     
func_test_mysqli_num_rows($link"SELECT 1 AS a"15);
35:     
func_test_mysqli_num_rows($link"SHOW VARIABLES LIKE '%nixnutz%'"010);
36:     
func_test_mysqli_num_rows($link"INSERT INTO test(id, label) VALUES (100, 'z')"NULL15);
37:     
func_test_mysqli_num_rows($link"SELECT id FROM test LIMIT 2"220true);
38:
39:     if (
$res mysqli_query($link'SELECT COUNT(id) AS num FROM test')) {
40:
41:         
$row mysqli_fetch_assoc($res);
42:         
mysqli_free_result($res);
43:
44:         
func_test_mysqli_num_rows($link"SELECT id, label FROM test", (int)$row['num'], 25);
45:
46:     } else {
47:         
printf("[030] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
48:     }
49:
50:     print 
"run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n";
51:
52:     if (
$res mysqli_query($link'SELECT id FROM test'MYSQLI_USE_RESULT)) {
53:
54:         
$row mysqli_fetch_row($res);
55:         if (
!== ($tmp mysqli_num_rows($res)))
56:             
printf("[031] Expecting int/0, got %s/%d\n"gettype($tmp), $tmp);
57:
58:         
mysqli_free_result($res);
59:
60:     } else {
61:         
printf("[032] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
62:     }
63:
64:     
mysqli_close($link);
65:     print 
"done!";
66:
?>
67:

Expected

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in %s on line %d

Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d

Warning: mysqli_num_rows(): Couldn't fetch mysqli_result in %s on line %d
run_tests.php don't fool me with your 'ungreedy' expression '.+?'!

Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
done!

Output

Out of memory

Diff

001+ Out of memory
001- Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in %s on line %d
002- 
003- Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in %s on line %d
004- 
005- Warning: mysqli_num_rows(): Couldn't fetch mysqli_result in %s on line %d
006- run_tests.php don't fool me with your 'ungreedy' expression '.+?'!
007- 
008- Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
009- done!

 

Generated at Mon, 27 Nov 2017 05:04:32 +0000 (18 days ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.