1--TEST--
2mysql_list_tables()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include_once "connect.inc";
11
12$tmp    = NULL;
13$link   = NULL;
14
15if (NULL !== ($tmp = @mysql_list_tables()))
16	printf("[001] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
17
18if (NULL !== ($tmp = @mysql_list_tables('too', 'many', 'arguments')))
19	printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
20
21if (false !== ($tmp = @mysql_list_tables(NULL)))
22	printf("[003] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp);
23
24if (NULL !== ($tmp = @mysql_list_tables($db, NULL)))
25	printf("[004] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
26
27require_once('table.inc');
28
29if (!$res_def = @mysql_list_tables($db))
30	printf("[005] [%d] %s\n", mysql_errno(), mysql_error());
31
32if (!$res = @mysql_list_tables($db, $link))
33	printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
34
35if (!$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
40while ($row = mysql_fetch_assoc($res_def))
41	$tables_def[] = $row;
42mysql_free_result($res_def);
43
44while ($row = mysql_fetch_assoc($res))
45	$tables[] = $row;
46mysql_free_result($res);
47
48while ($row = mysql_fetch_assoc($res_query))
49	$tables_query[] = $row;
50mysql_free_result($res_query);
51
52if ($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();
59foreach ($tables as $k => $tlist)
60	foreach ($tlist as $k => $table)
61		$list1[] = $table;
62
63foreach ($tables_query as $k => $tlist)
64	foreach ($tlist as $k => $table)
65		$list2[] = $table;
66
67if ($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
73if (!in_array('test', $list1))
74	printf("[010] Table lists seem to be wrong. Check manually.\n");
75
76mysql_close($link);
77
78print "done!\n";
79?>
80--CLEAN--
81<?php
82require_once("clean_table.inc");
83?>
84--EXPECTF--
85done!
86