xref: /PHP-8.2/ext/mysqli/tests/mysqli_ping.phpt (revision b5a14e6c)
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
13    require('table.inc');
14
15    var_dump(mysqli_ping($link));
16
17    // provoke an error to check if mysqli_ping resets it
18    $res = mysqli_query($link, 'SELECT * FROM unknown_table');
19    if (!($errno = mysqli_errno($link)))
20        printf("[003] Statement should have caused an error\n");
21
22    var_dump(mysqli_ping($link));
23    if ($errno === mysqli_errno($link))
24        printf("[004] Error codes should have been reset\n");
25
26    mysqli_close($link);
27
28    try {
29        mysqli_ping($link);
30    } catch (Error $exception) {
31        echo $exception->getMessage() . "\n";
32    }
33
34    print "done!";
35?>
36--EXPECT--
37bool(true)
38bool(true)
39mysqli object is already closed
40done!
41