Annotation of embedaddon/php/ext/mysql/tests/mysql_list_tables.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysql_list_tables()
3: --SKIPIF--
4: <?php
5: require_once('skipif.inc');
6: require_once('skipifconnectfailure.inc');
7: ?>
8: --FILE--
9: <?php
10: include_once "connect.inc";
11:
12: $tmp = NULL;
13: $link = NULL;
14:
15: if (NULL !== ($tmp = @mysql_list_tables()))
16: printf("[001] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
17:
18: if (NULL !== ($tmp = @mysql_list_tables('too', 'many', 'arguments')))
19: printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
20:
21: if (false !== ($tmp = @mysql_list_tables(NULL)))
22: printf("[003] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp);
23:
24: if (NULL !== ($tmp = @mysql_list_tables($db, NULL)))
25: printf("[004] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
26:
27: require_once('table.inc');
28:
29: if (!$res_def = @mysql_list_tables($db))
30: printf("[005] [%d] %s\n", mysql_errno(), mysql_error());
31:
32: if (!$res = @mysql_list_tables($db, $link))
33: printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
34:
35: if (!$res_query = mysql_query("SHOW TABLES", $link))
36: printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
37:
38: $tables_def = $tables = $tables_query = array();
39:
40: while ($row = mysql_fetch_assoc($res_def))
41: $tables_def[] = $row;
42: mysql_free_result($res_def);
43:
44: while ($row = mysql_fetch_assoc($res))
45: $tables[] = $row;
46: mysql_free_result($res);
47:
48: while ($row = mysql_fetch_assoc($res_query))
49: $tables_query[] = $row;
50: mysql_free_result($res_query);
51:
52: if ($tables_def !== $tables) {
53: printf("[008] Got different table lists for default link and specified link\n");
54: var_dump($tables_def);
55: var_dump($tables);
56: }
57:
58: $list1 = $list2 = array();
59: foreach ($tables as $k => $tlist)
60: foreach ($tlist as $k => $table)
61: $list1[] = $table;
62:
63: foreach ($tables_query as $k => $tlist)
64: foreach ($tlist as $k => $table)
65: $list2[] = $table;
66:
67: if ($list1 !== $list2) {
68: printf("[009] Got different results for mysql_list_tables() and SHOW TABLES\n");
69: var_dump($list1);
70: var_dump($list2);
71: }
72:
73: if (!in_array('test', $list1))
74: printf("[010] Table lists seem to be wrong. Check manually.\n");
75:
76: mysql_close($link);
77:
78: print "done!\n";
79: ?>
80: --CLEAN--
81: <?php
82: require_once("clean_table.inc");
83: ?>
84: --EXPECTF--
85: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>