xref: /PHP-5.6/ext/pdo_sqlite/tests/bug46139.phpt (revision 6f81d12e)
1--TEST--
2Bug #46139 (PDOStatement->setFetchMode() forgets FETCH_PROPS_LATE)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
6?>
7--FILE--
8<?php
9
10require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
11$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
12
13class Person {
14    public $test = NULL;
15    public function __construct() {
16        var_dump($this->test);
17    }
18}
19
20$stmt = $db->query("SELECT 'foo' test, 1");
21$stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Person');
22$r1 = $stmt->fetch();
23printf("'%s'\n", $r1->test);
24
25$stmt = $db->query("SELECT 'foo' test, 1");
26$stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Person');
27$r1 = $stmt->fetchAll();
28printf("'%s'\n", $r1[0]->test);
29
30$stmt = $db->query("SELECT 'foo' test, 1");
31$stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Person');
32$r1 = $stmt->fetch(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE);
33printf("'%s'\n", $r1->test);
34
35?>
36--EXPECT--
37NULL
38'foo'
39NULL
40'foo'
41NULL
42'foo'
43