xref: /PHP-8.0/ext/mysqli/tests/mysqli_ping.phpt (revision e3e67b72)
1--TEST--
2mysqli_ping()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    require_once("connect.inc");
11
12    require('table.inc');
13
14    var_dump(mysqli_ping($link));
15
16    // provoke an error to check if mysqli_ping resets it
17    $res = mysqli_query($link, 'SELECT * FROM unknown_table');
18    if (!($errno = mysqli_errno($link)))
19        printf("[003] Statement should have caused an error\n");
20
21    var_dump(mysqli_ping($link));
22    if ($errno === mysqli_errno($link))
23        printf("[004] Error codes should have been reset\n");
24
25    mysqli_close($link);
26
27    try {
28        mysqli_ping($link);
29    } catch (Error $exception) {
30        echo $exception->getMessage() . "\n";
31    }
32
33    print "done!";
34?>
35--EXPECT--
36bool(true)
37bool(true)
38mysqli object is already closed
39done!
40