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_stmt_num_rows.phpt ('mysqli_stmt_num_rows()')

Script

1: <?php
2:     
require_once("connect.inc");
3:
4:     
$tmp    NULL;
5:     
$link   NULL;
6:
7:     if (!
is_null($tmp = @mysqli_stmt_num_rows()))
8:         
printf("[001] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
9:
10:     if (!
is_null($tmp = @mysqli_stmt_num_rows($link)))
11:         
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
12:
13:     require(
'table.inc');
14:
15:     if (!
$stmt mysqli_stmt_init($link))
16:         
printf("[003] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
17:
18:     function 
func_test_mysqli_stmt_num_rows($stmt$query$expected$offset) {
19:
20:         if (!
mysqli_stmt_prepare($stmt$query)) {
21:             
printf("[%03d] [%d] %s\n"$offsetmysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
22:             return 
false;
23:         }
24:
25:         if (!
mysqli_stmt_execute($stmt)) {
26:             
printf("[%03d] [%d] %s\n"$offset 1mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
27:             return 
false;
28:         }
29:
30:         if (!
mysqli_stmt_store_result($stmt)) {
31:             
printf("[%03d] [%d] %s\n"$offset 2mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
32:             return 
false;
33:         }
34:
35:         if (
$expected !== ($tmp mysqli_stmt_num_rows($stmt)))
36:             
printf("[%03d] Expecting %s/%d, got %s/%d\n"$offset 3,
37:                 
gettype($expected), $expected,
38:                 
gettype($tmp), $tmp);
39:
40:         
mysqli_stmt_free_result($stmt);
41:
42:         return 
true;
43:     }
44:
45:     
func_test_mysqli_stmt_num_rows($stmt"SELECT 1 AS a"110);
46:     
func_test_mysqli_stmt_num_rows($stmt"SHOW VARIABLES LIKE '%nixnutz%'"020);
47:     
// Note: for statements that return no result set mysqli_num_rows() differs from mysqli_stmt_num_rows() slightly
48:     // mysqli_num_rows() failed to fetch the result set and the PHP parameter check makes it return NULL
49:     // mysqli_stmt_numrows() has a valid resource to work on and it will return int/0 instead. No bug, but
50:     // slightly different behaviour... - if you really check the data types and don't rely on casting like 98% of all PHP
51:     // users do.
52:     
func_test_mysqli_stmt_num_rows($stmt"INSERT INTO test(id, label) VALUES (100, 'z')"030);
53:
54:     if (
$res mysqli_query($link'SELECT COUNT(id) AS num FROM test')) {
55:         
$row mysqli_fetch_assoc($res);
56:         
mysqli_free_result($res);
57:         
func_test_mysqli_stmt_num_rows($stmt"SELECT id, label FROM test", (int)$row['num'], 40);
58:     } else {
59:         
printf("[050] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
60:     }
61:
62:     print 
"run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n";
63:
64:     if (!
mysqli_stmt_prepare($stmt'SELECT id FROM test'))
65:         
printf("[051] [%d] %s\n"mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
66:
67:     if (
mysqli_stmt_execute($stmt)) {
68:
69:         
$i 0;
70:         do {
71:             if (
!== ($tmp mysqli_stmt_num_rows($stmt)))
72:                 
printf("[53 - %03d] Expecting int/0, got %s/%s\n"$igettype($tmp), $tmp);
73:             
$i++;
74:         } while (
mysqli_stmt_fetch($stmt));
75:
76:         
/* NOTE to users
77:         Behaviour with libmysql is UNDEFINED, see http://news.php.net/php.internals/55210
78:         Because it is undefined it is allowed to the mysqlnd DEVELOPER to implement
79:         any behaviour they like, including the one checked for in this test.
80:         What the test does is cover an implementation detail of the mysqlnd library.
81:         This implementation detail may, at any time, change without prior notice.
82:         On the contrary, the mysqlnd way is a reasonable one and, maybe, one fine
83:         day, after Klingons visited earh, becomes the official one. Meanwhile do
84:         not rely on it.
85:         */
86:         
if ($IS_MYSQLND && (!== ($tmp mysqli_stmt_num_rows($stmt))))
87:             
printf("[54] Expecting int/7, got %s/%s\n"gettype($tmp), $tmp);
88:
89:     } else {
90:         
printf("[055] [%d] %s\n"mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
91:     }
92:
93:     
mysqli_stmt_close($stmt);
94:
95:     if (
NULL !== ($tmp mysqli_stmt_num_rows($stmt)))
96:         
printf("[056] Expecting NULL, got %s/%s\n");
97:
98:     
mysqli_close($link);
99:     print 
"done!";
100:
?>
101:

Expected

run_tests.php don't fool me with your 'ungreedy' expression '.+?'!

Warning: mysqli_stmt_num_rows(): Couldn't fetch mysqli_stmt in %s on line %d
done!

Output

Out of memory

Diff

001+ Out of memory
001- run_tests.php don't fool me with your 'ungreedy' expression '.+?'!
002- 
003- Warning: mysqli_stmt_num_rows(): Couldn't fetch mysqli_stmt in %s on line %d
004- done!

 

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

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