1--TEST--
2$mysqli->errno
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    $tmp    = NULL;
14    $link   = NULL;
15
16    $mysqli = new mysqli();
17    if (0 !== ($tmp = @$mysqli->errno))
18        printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
19
20    if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
21        printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
22            $host, $user, $db, $port, $socket);
23
24    var_dump($mysqli->errno);
25
26    if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
27        printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error);
28    }
29
30    $mysqli->query('SELECT * FROM test');
31    var_dump($mysqli->errno);
32
33    @$mysqli->query('No SQL');
34    if (($tmp = $mysqli->errno) === 0)
35        printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp);
36
37    $mysqli->close();
38
39    try {
40        $mysqli->errno;
41    } catch (Error $exception) {
42        echo $exception->getMessage() . "\n";
43    }
44
45    print "done!";
46?>
47--EXPECTF--
48int(0)
49int(%d)
50mysqli object is already closed
51done!
52