1--TEST--
2mysql_field_seek()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include "connect.inc";
11
12$tmp    = NULL;
13$link   = NULL;
14
15if (!is_null($tmp = @mysql_field_seek()))
16	printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
17
18if (!is_null($tmp = @mysql_field_seek($link)))
19	printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
20
21require('table.inc');
22if (!$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
26var_dump(mysql_field_seek($res, -1));
27var_dump(mysql_fetch_field($res));
28var_dump(mysql_field_seek($res, 0));
29var_dump(mysql_fetch_field($res));
30var_dump(mysql_field_seek($res, 1));
31var_dump(mysql_fetch_field($res));
32var_dump(mysql_field_seek($res, 2));
33var_dump(mysql_fetch_field($res));
34
35mysql_free_result($res);
36
37var_dump(mysql_field_seek($res, 0));
38
39mysql_close($link);
40print "done!";
41?>
42--CLEAN--
43<?php
44require_once("clean_table.inc");
45?>
46--EXPECTF--
47Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d
48bool(false)
49object(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}
77bool(true)
78object(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}
106bool(true)
107object(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
136Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d
137bool(false)
138bool(false)
139
140Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d
141bool(false)
142done!
143