Annotation of embedaddon/php/ext/mysql/tests/mysql_list_fields.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysql_list_fields()
3: --SKIPIF--
4: <?php
5: require_once 'skipif.inc';
6: require_once 'skipifconnectfailure.inc';
7: ?>
8: --FILE--
9: <?php
10: require_once 'connect.inc';
11:
12: $tmp = NULL;
13: $link = NULL;
14:
15: require 'table.inc';
16:
17: if (!$res = mysql_list_fields($db, 'test', $link))
18: printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
19:
20: if (2 !== ($num = mysql_num_fields($res)))
21: printf("[004] Expecting two fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
22:
23: mysql_free_result($res);
24:
25: if (!mysql_query("DROP TABLE IF EXISTS test2", $link))
26: printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
27:
28: if (!$res = @mysql_list_fields($db, 'test2', $link))
29: printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
30:
31: if (!$res = mysql_list_fields($db, 'test', $link))
32: printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
33:
34: if (2 !== ($num = mysql_num_fields($res)))
35: printf("[008] Expecting 2 fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
36:
37: var_dump(mysql_fetch_assoc($res));
38: for ($field_offset = 0; $field_offset < mysql_num_fields($res); $field_offset++) {
39: printf("Field Offset %d\n", $field_offset);
40: printf("mysql_field_flags(): %s\n", mysql_field_flags($res, $field_offset));
41: printf("mysql_field_len(): %s\n", mysql_field_len($res, $field_offset));
42: printf("mysql_field_name(): %s\n", mysql_field_name($res, $field_offset));
43: printf("mysql_field_type(): %s\n", mysql_field_type($res, $field_offset));
44: }
45:
46: mysql_free_result($res);
47: mysql_close($link);
48:
49: print "done!";
50: ?>
51: --CLEAN--
52: <?php
53: require_once 'connect.inc';
54: if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
55: printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
56: $host, $user, $db, $port, $socket);
57:
58: if (!mysql_query("DROP TABLE IF EXISTS test", $link))
59: printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
60:
61: if (!mysql_query("DROP TABLE IF EXISTS test2", $link))
62: printf("[c002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
63:
64: mysql_close($link);
65: ?>
66: --EXPECTF--
67: [006] [%d] %s
68: bool(false)
69: Field Offset 0
70: mysql_field_flags()%s
71: mysql_field_len(): 11
72: mysql_field_name(): id
73: mysql_field_type(): int
74: Field Offset 1
75: mysql_field_flags()%s
76: mysql_field_len(): 1
77: mysql_field_name(): label
78: mysql_field_type(): string
79: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>