xref: /PHP-5.4/ext/mysql/tests/mysql_ping.phpt (revision 5147f6cf)
1--TEST--
2mysql_ping()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10include_once "connect.inc";
11
12$tmp    = NULL;
13$link   = NULL;
14
15require('table.inc');
16
17if (!is_null($tmp = @mysql_ping($link, $link)))
18	printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
19
20var_dump(mysql_ping($link));
21
22// provoke an error to check if mysql_ping resets it
23$res = mysql_query('SELECT * FROM unknown_table', $link);
24if (!($errno = mysql_errno($link)))
25	printf("[002] Statement should have caused an error\n");
26
27var_dump(mysql_ping($link));
28
29if ($errno === mysql_errno($link))
30	printf("[003] Error codes should have been reset\n");
31
32var_dump(mysql_ping());
33mysql_close($link);
34
35if (false !== ($tmp = mysql_ping($link)))
36	printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
37
38print "done!";
39?>
40--CLEAN--
41<?php
42require_once("clean_table.inc");
43?>
44--EXPECTF--
45bool(true)
46bool(true)
47bool(true)
48
49Warning: mysql_ping(): %d is not a valid MySQL-Link resource in %s on line %d
50done!
51