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