xref: /PHP-8.0/ext/mysqli/tests/bug36949.phpt (revision e3e67b72)
1--TEST--
2Bug #36949 (invalid internal mysqli objects dtor)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10require_once("connect.inc");
11class A {
12
13    private $mysqli;
14
15    public function __construct() {
16        global $user, $host, $passwd, $db, $port, $socket;
17        $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
18        $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL");
19        $row = $result->fetch_object();
20        echo $row->my_time."<br>\n";
21        $result->close();
22    }
23
24    public function __destruct() {
25        $this->mysqli->close();
26    }
27}
28
29class B {
30
31    private $mysqli;
32
33    public function __construct() {
34        global $user, $host, $passwd, $db, $port, $socket;
35        $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
36        $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL");
37        $row = $result->fetch_object();
38        echo $row->my_time."<br>\n";
39        $result->close();
40    }
41
42    public function __destruct() {
43        $this->mysqli->close();
44    }
45}
46
47$A = new A();
48$B = new B();
49?>
50--CLEAN--
51<?php
52require_once("connect.inc");
53if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
54   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
55
56if (!mysqli_query($link, "DROP TABLE IF EXISTS my_time"))
57    printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
58
59mysqli_close($link);
60?>
61--EXPECTF--
62%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d<br>
63%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d<br>
64