xref: /PHP-5.6/ext/mysql/tests/002.phpt (revision b7091aaf)
1--TEST--
2mysql_fetch_array
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
16var_dump($link);
17
18var_dump(mysql_query('DROP TABLE IF EXISTS test'));
19
20var_dump(mysql_query('CREATE TABLE test(col1 int PRIMARY KEY, col2 varchar(50), col3 char(5))'));
21
22var_dump(mysql_query("INSERT INTO test(col1, col2, col3) VALUES(1, 'foo', 'bar'),(2, 'foo', 'bar')"));
23
24var_dump($res = mysql_query('SELECT col1, col2, col3 FROM test ORDER BY col1 ASC'));
25
26while ($data = mysql_fetch_array($res, MYSQL_ASSOC)) {
27	var_dump($data);
28}
29
30mysql_free_result($res);
31mysql_close($link);
32
33print "done!";
34?>
35--CLEAN--
36<?php
37require_once("clean_table.inc");
38?>
39--EXPECTF--
40Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
41resource(%d) of type (mysql link)
42bool(true)
43bool(true)
44bool(true)
45resource(%d) of type (mysql result)
46array(3) {
47  [%u|b%"col1"]=>
48  %unicode|string%(1) "1"
49  [%u|b%"col2"]=>
50  %unicode|string%(3) "foo"
51  [%u|b%"col3"]=>
52  %unicode|string%(3) "bar"
53}
54array(3) {
55  [%u|b%"col1"]=>
56  %unicode|string%(1) "2"
57  [%u|b%"col2"]=>
58  %unicode|string%(3) "foo"
59  [%u|b%"col3"]=>
60  %unicode|string%(3) "bar"
61}
62done!
63