xref: /php-src/ext/mysqli/tests/mysqli_ping.phpt (revision 7e5171d1)
1--TEST--
2mysqli_ping()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    require_once 'connect.inc';
12    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
13        printf("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        exit(1);
16    }
17
18    var_dump(mysqli_ping($link));
19
20    // provoke an error to check if mysqli_ping resets it
21    mysqli_query($link, 'SELECT * FROM unknown_table');
22    if (!($errno = mysqli_errno($link)))
23        printf("[003] Statement should have caused an error\n");
24
25    var_dump(mysqli_ping($link));
26    if ($errno === mysqli_errno($link))
27        printf("[004] Error codes should have been reset\n");
28
29    mysqli_close($link);
30
31    try {
32        mysqli_ping($link);
33    } catch (Error $exception) {
34        echo $exception->getMessage() . "\n";
35    }
36
37    print "done!";
38?>
39--EXPECTF--
40
41Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s
42bool(true)
43
44Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s
45bool(true)
46
47Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s
48mysqli object is already closed
49done!
50