xref: /PHP-7.4/ext/mysqli/tests/bug34785.phpt (revision e3e67b72)
1--TEST--
2Bug #34785 (Can not properly subclass mysqli_stmt)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    include ("connect.inc");
11
12    class my_stmt extends mysqli_stmt
13    {
14        public function __construct($link, $query) {
15            parent::__construct($link, $query);
16        }
17    }
18
19    class my_result extends mysqli_result
20    {
21        public function __construct($link, $query) {
22            parent::__construct($link, $query);
23        }
24    }
25
26    /*** test mysqli_connect 127.0.0.1 ***/
27    $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
28    mysqli_query($link, "SET sql_mode=''");
29
30    $stmt = new my_stmt($link, "SELECT 'foo' FROM DUAL");
31
32    $stmt->execute();
33    $stmt->bind_result($var);
34    $stmt->fetch();
35
36    $stmt->close();
37    var_dump($var);
38
39    mysqli_real_query($link, "SELECT 'bar' FROM DUAL");
40    $result = new my_result($link, MYSQLI_STORE_RESULT);
41    $row = $result->fetch_row();
42    $result->close();
43
44    var_dump($row[0]);
45
46    mysqli_close($link);
47?>
48--EXPECTF--
49%s(3) "foo"
50%s(3) "bar"
51