xref: /PHP-8.4/ext/pdo_sqlite/tests/bug48773.phpt (revision 74859783)
1--TEST--
2Bug #48773 (Incorrect error when setting PDO::ATTR_STATEMENT_CLASS with ctor_args)
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7
8class bar extends PDOStatement {
9    private function __construct() {
10    }
11}
12
13class foo extends PDO {
14    public $statementClass = 'bar';
15    function __construct($dsn, $username, $password, $driver_options = array()) {
16        $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
17        parent::__construct($dsn, $username, $password, $driver_options);
18
19        $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
20    }
21}
22
23$db = new foo('sqlite::memory:', '', '');
24$stmt = $db->query('SELECT 1');
25var_dump($stmt);
26
27?>
28--EXPECTF--
29object(bar)#%d (1) {
30  ["queryString"]=>
31  string(8) "SELECT 1"
32}
33