xref: /PHP-8.0/ext/mysqli/tests/063.phpt (revision 233f507f)
1--TEST--
2resultset constructor
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    require_once("connect.inc");
11
12    $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
13
14    $stmt = new mysqli_stmt($mysql, "SELECT 'foo' FROM DUAL");
15    $stmt->execute();
16    $stmt->bind_result($foo);
17    $stmt->fetch();
18    $stmt->close();
19    var_dump($foo);
20
21    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
22    try {
23        // an exception should be thrown from prepare (i.e. constructor) not from execute
24        $stmt = new mysqli_stmt($mysql, "SELECT invalid FROM DUAL");
25    } catch(mysqli_sql_exception $e) {
26        echo $e->getMessage()."\n";
27    }
28
29    $mysql->close();
30?>
31--EXPECT--
32string(3) "foo"
33Unknown column 'invalid' in 'field list'
34