xref: /PHP-5.4/ext/mysql/tests/mysql_info.phpt (revision 759cc732)
1--TEST--
2mysql_info()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include "connect.inc";
11
12if (false !== ($tmp = @mysql_info()))
13	printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
14
15if (NULL !== ($tmp = @mysql_info(NULL)))
16	printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
17
18require "table.inc";
19if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (100, 'a')", $link))
20	printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
21
22if (false !== ($tmp = mysql_info($link)))
23	printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
24
25if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')", $link))
26	printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
27
28if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
29	printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
30
31if (!$res = mysql_query('INSERT INTO test(id, label) SELECT id + 200, label FROM test', $link))
32	printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
33
34if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
35	printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
36
37if (!$res = mysql_query('ALTER TABLE test MODIFY label CHAR(2)', $link))
38	printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
39
40if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
41	printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
42
43if (!$res = mysql_query("UPDATE test SET label = 'b' WHERE id >= 100", $link))
44	printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
45
46if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
47	printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
48
49if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp)) {
50	printf("[013] Expecting Unicode!\n");
51	var_inspect($info);
52}
53
54if (!is_string($def_tmp = mysql_info()) || ('' == $def_tmp))
55	printf("[014] Expecting string/any_non_empty, got %s/%s\n", gettype($def_tmp), $def_tmp);
56
57if ($def_tmp !== $tmp) {
58	printf("[015] Results differ for default link and specified link, [%d] %s\n",
59		mysql_errno(), mysql_error());
60	var_inspect($tmp);
61	var_inspect($def_tmp);
62}
63
64// NOTE: no LOAD DATA INFILE test
65
66print "done!";
67?>
68--CLEAN--
69<?php
70require_once("clean_table.inc");
71?>
72--EXPECTF--
73done!