Annotation of embedaddon/php/ext/mysql/tests/mysql_field_seek.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysql_field_seek()
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_field_seek()))
16: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
17:
18: if (!is_null($tmp = @mysql_field_seek($link)))
19: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
20:
21: require('table.inc');
22: if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) {
23: printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
24: }
25:
26: var_dump(mysql_field_seek($res, -1));
27: var_dump(mysql_fetch_field($res));
28: var_dump(mysql_field_seek($res, 0));
29: var_dump(mysql_fetch_field($res));
30: var_dump(mysql_field_seek($res, 1));
31: var_dump(mysql_fetch_field($res));
32: var_dump(mysql_field_seek($res, 2));
33: var_dump(mysql_fetch_field($res));
34:
35: mysql_free_result($res);
36:
37: var_dump(mysql_field_seek($res, 0));
38:
39: mysql_close($link);
40: print "done!";
41: ?>
42: --CLEAN--
43: <?php
44: require_once("clean_table.inc");
45: ?>
46: --EXPECTF--
47: Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d
48: bool(false)
49: object(stdClass)#%d (13) {
50: [%u|b%"name"]=>
51: %unicode|string%(2) "id"
52: [%u|b%"table"]=>
53: %unicode|string%(4) "test"
54: [%u|b%"def"]=>
55: %unicode|string%(0) ""
56: [%u|b%"max_length"]=>
57: int(1)
58: [%u|b%"not_null"]=>
59: int(1)
60: [%u|b%"primary_key"]=>
61: int(1)
62: [%u|b%"multiple_key"]=>
63: int(0)
64: [%u|b%"unique_key"]=>
65: int(0)
66: [%u|b%"numeric"]=>
67: int(1)
68: [%u|b%"blob"]=>
69: int(0)
70: [%u|b%"type"]=>
71: %unicode|string%(3) "int"
72: [%u|b%"unsigned"]=>
73: int(0)
74: [%u|b%"zerofill"]=>
75: int(0)
76: }
77: bool(true)
78: object(stdClass)#%d (13) {
79: [%u|b%"name"]=>
80: %unicode|string%(2) "id"
81: [%u|b%"table"]=>
82: %unicode|string%(4) "test"
83: [%u|b%"def"]=>
84: %unicode|string%(0) ""
85: [%u|b%"max_length"]=>
86: int(1)
87: [%u|b%"not_null"]=>
88: int(1)
89: [%u|b%"primary_key"]=>
90: int(1)
91: [%u|b%"multiple_key"]=>
92: int(0)
93: [%u|b%"unique_key"]=>
94: int(0)
95: [%u|b%"numeric"]=>
96: int(1)
97: [%u|b%"blob"]=>
98: int(0)
99: [%u|b%"type"]=>
100: %unicode|string%(3) "int"
101: [%u|b%"unsigned"]=>
102: int(0)
103: [%u|b%"zerofill"]=>
104: int(0)
105: }
106: bool(true)
107: object(stdClass)#%d (13) {
108: [%u|b%"name"]=>
109: %unicode|string%(5) "label"
110: [%u|b%"table"]=>
111: %unicode|string%(4) "test"
112: [%u|b%"def"]=>
113: %unicode|string%(0) ""
114: [%u|b%"max_length"]=>
115: int(1)
116: [%u|b%"not_null"]=>
117: int(0)
118: [%u|b%"primary_key"]=>
119: int(0)
120: [%u|b%"multiple_key"]=>
121: int(0)
122: [%u|b%"unique_key"]=>
123: int(0)
124: [%u|b%"numeric"]=>
125: int(0)
126: [%u|b%"blob"]=>
127: int(0)
128: [%u|b%"type"]=>
129: %unicode|string%(6) "string"
130: [%u|b%"unsigned"]=>
131: int(0)
132: [%u|b%"zerofill"]=>
133: int(0)
134: }
135:
136: Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d
137: bool(false)
138: bool(false)
139:
140: Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d
141: bool(false)
142: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>