xref: /PHP-5.5/ext/mysql/tests/bug47438.phpt (revision b7091aaf)
1--TEST--
2Bug #47438 (mysql_fetch_field ignores zero offset)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10require_once('connect.inc');
11
12if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
13        printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
14                $host, $user, $db, $port, $socket);
15
16mysql_select_db($db, $link);
17mysql_query("DROP TABLE IF EXISTS test_47438", $link);
18mysql_query("CREATE TABLE test_47438 (a INT, b INT, c INT)", $link);
19mysql_query("INSERT INTO test_47438 VALUES (10, 11, 12), (20, 21, 22)", $link);
20$result = mysql_query("SELECT * FROM test_47438", $link);
21mysql_field_seek($result, 1);
22
23$i = 0;
24
25while($i<mysql_num_fields($result))
26{
27  $meta=mysql_fetch_field($result,$i);
28  echo $i . "." . $meta->name . "\n";
29  $i++;
30}
31
32mysql_query("DROP TABLE IF EXISTS test_47438", $link);
33
34?>
35--CLEAN--
36<?php
37require_once('connect.inc');
38
39if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
40        printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
41                $host, $user, $db, $port, $socket);
42
43if (!mysql_select_db($db, $link) ||
44	!mysql_query("DROP TABLE IF EXISTS test_47438", $link))
45	printf("[c002] [%d] %s\n", mysql_errno($link), mysql_error($link));
46
47mysql_close($link);
48?>
49--EXPECTF--
50Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
510.a
521.b
532.c
54