xref: /PHP-5.5/ext/mysql/tests/mysql_db_query.phpt (revision b7091aaf)
1--TEST--
2mysql_db_query()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include "connect.inc";
11
12// NOTE: this function is deprecated. We do only the most necessary
13// to test it. We don't test all aspects of the documented behaviour.
14
15$tmp    = NULL;
16$link   = NULL;
17
18if (NULL !== ($tmp = @mysql_db_query()))
19	printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
20
21if (NULL !== ($tmp = @mysql_db_query($link)))
22	printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
23
24if (NULL !== ($tmp = @mysql_db_query($link)))
25	printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
26
27require('table.inc');
28if (!$res = @mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1', $link))
29	printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
30
31$row = mysql_fetch_assoc($res);
32if (1 != $row['id'])
33	printf("[005] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
34
35if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row['label'])) {
36	printf("[006] No unicode returned! [%d] %s\n", mysql_errno($link), mysql_error($link));
37	var_inspect($row);
38}
39
40mysql_free_result($res);
41
42
43if (!$res = @mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1'))
44	printf("[007] [%d] %s\n", mysql_errno(), mysql_error());
45
46$row = mysql_fetch_assoc($res);
47if (1 != $row['id'])
48	printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
49
50if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row['label'])) {
51	printf("[009] No unicode returned! [%d] %s\n", mysql_errno(), mysql_error());
52	var_inspect($row);
53}
54
55mysql_free_result($res);
56mysql_close($link);
57
58print "done!\n";
59?>
60--CLEAN--
61<?php
62require_once("clean_table.inc");
63?>
64--EXPECTF--
65Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
66done!
67