Annotation of embedaddon/php/ext/mysql/tests/mysql_num_fields.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysql_num_fields()
3: --SKIPIF--
4: <?php
5: require_once('skipif.inc');
6: require_once('skipifconnectfailure.inc');
7: ?>
8: --FILE--
9: <?php
10: include "connect.inc";
11:
12: $tmp = NULL;
13: $link = NULL;
14:
15: if (!is_null($tmp = @mysql_num_fields()))
16: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
17:
18: if (NULL !== ($tmp = @mysql_num_fields($link)))
19: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
20:
21: require('table.inc');
22:
23: function func_test_mysql_num_fields($link, $query, $expected, $offset, $test_free = false) {
24:
25: if (!($res = mysql_query($query, $link))) {
26: printf("[%03d] [%d] %s\n", $offset, mysql_errno($link), mysql_error($link));
27: return;
28: }
29:
30: if ($expected !== ($tmp = mysql_num_fields($res)))
31: printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 1,
32: gettype($expected), $expected,
33: gettype($tmp), $tmp);
34:
35: mysql_free_result($res);
36:
37: if ($test_free && (false !== ($tmp = mysql_num_fields($res))))
38: printf("[%03d] Expecting boolean/false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp);
39: }
40:
41: func_test_mysql_num_fields($link, "SELECT 1 AS a", 1, 5);
42: func_test_mysql_num_fields($link, "SELECT id, label FROM test", 2, 10);
43: func_test_mysql_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15);
44: func_test_mysql_num_fields($link, "SELECT id FROM test", 1, 20, true);
45:
46: mysql_close($link);
47:
48: print "done!";
49: ?>
50: --CLEAN--
51: <?php
52: require_once("clean_table.inc");
53: ?>
54: --EXPECTF--
55: Warning: mysql_num_fields(): %d is not a valid MySQL result resource in %s on line %d
56: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>