summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/bug29311.phpt
blob: a5808418bfdb94825b24970ef131254523f8d828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--TEST--
Bug #29311 (Cannot override mysqli constructor)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
    require_once("connect.inc");

    /* class 1 calls parent constructor */
    class mysql1 extends mysqli {
        function __construct() {
            global $host, $user, $passwd, $db, $port, $socket;
            parent::__construct($host, $user, $passwd, $db, $port, $socket);
        }
    }

    /* class 2 has an own constructor */
    class mysql2 extends mysqli {

        function __construct() {
            global $host, $user, $passwd, $db, $port, $socket;
            $this->connect($host, $user, $passwd, $db, $port, $socket);
        }
    }

    /* class 3 has no constructor */
    class mysql3 extends mysqli {

    }

    $foo[0] = new mysql1();
    $foo[1] = new mysql2();
    $foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket);


    for ($i=0; $i < 3; $i++) {
        if (($result = $foo[$i]->query("SELECT DATABASE()"))) {
            $row = $result->fetch_row();
            if ($row[0] != $db)
                printf("%d: %s\n", $i, $row[0]);
            $result->close();
        }
        $foo[$i]->close();
    }
    print "done!";
?>
--EXPECT--
done!