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