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