1--TEST--
2mysql_data_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 (NULL !== ($tmp = @mysql_data_seek()))
16	printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
17
18if (NULL !== ($tmp = @mysql_data_seek($link)))
19	printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
20
21if (NULL !== ($tmp = @mysql_data_seek($link, $link)))
22	printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
23
24require('table.inc');
25if (!$res = mysql_query('SELECT * FROM test ORDER BY id LIMIT 4', $link))
26	printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
27
28if (true !== ($tmp = mysql_data_seek($res, 3)))
29	printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
30
31$row = mysql_fetch_assoc($res);
32if (4 != $row['id'])
33	printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']);
34
35if (true !== ($tmp = mysql_data_seek($res, 0)))
36	printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
37
38$row = mysql_fetch_assoc($res);
39if (1 != $row['id'])
40	printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
41
42if (false !== ($tmp = mysql_data_seek($res, 4)))
43	printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
44
45if (false !== ($tmp = mysql_data_seek($res, -1)))
46	printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
47
48mysql_free_result($res);
49
50if (!$res = mysql_unbuffered_query('SELECT * FROM test ORDER BY id', $link))
51	printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
52
53if (false !== ($tmp = mysql_data_seek($res, 3)))
54	printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
55
56mysql_free_result($res);
57
58if (false !== ($tmp = mysql_data_seek($res, 1)))
59	printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
60
61mysql_close($link);
62
63print "done!\n";
64?>
65--CLEAN--
66<?php
67require_once("clean_table.inc");
68?>
69--EXPECTF--
70Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
71
72Warning: mysql_data_seek(): Offset -1 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
73
74Warning: mysql_data_seek(): Offset 3 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
75
76Warning: mysql_data_seek(): %d is not a valid MySQL result resource in %s on line %d
77done!
78