1--TEST-- 2Bug #46292 (PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_CLASSTYPE) 3--EXTENSIONS-- 4pdo_mysql 5--SKIPIF-- 6<?php 7require_once __DIR__ . '/inc/mysql_pdo_test.inc'; 8MySQLPDOTest::skip(); 9?> 10--FILE-- 11<?php 12 require_once __DIR__ . '/inc/mysql_pdo_test.inc'; 13 $pdoDb = MySQLPDOTest::factory(); 14 15 class myclass { 16 public $value; 17 18 public function __construct() { 19 printf("%s()\n", __METHOD__); 20 } 21 } 22 23 class myclass2 extends myclass { } 24 25 $pdoDb->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 26 $pdoDb->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); 27 28 $pdoDb->query('CREATE TABLE test_46292 (name VARCHAR(20) NOT NULL, value INT)'); 29 30 $pdoDb->query("INSERT INTO test_46292 VALUES ('myclass', 1), ('myclass2', 2), ('myclass', NULL), ('myclass3', NULL)"); 31 32 $stmt = $pdoDb->prepare("SELECT * FROM test_46292"); 33 34 var_dump($stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_GROUP)); 35 $stmt->execute(); 36 37 var_dump($stmt->fetch()); 38 var_dump($stmt->fetch()); 39 var_dump($stmt->fetchAll()); 40?> 41--CLEAN-- 42<?php 43require_once __DIR__ . '/inc/mysql_pdo_test.inc'; 44$db = MySQLPDOTest::factory(); 45$db->exec('DROP TABLE IF EXISTS test_46292'); 46?> 47--EXPECTF-- 48bool(true) 49myclass::__construct() 50object(myclass)#%d (1) { 51 ["value"]=> 52 string(1) "1" 53} 54myclass::__construct() 55object(myclass2)#%d (1) { 56 ["value"]=> 57 string(1) "2" 58} 59myclass::__construct() 60array(2) { 61 [0]=> 62 object(myclass)#%d (1) { 63 ["value"]=> 64 NULL 65 } 66 [1]=> 67 object(stdClass)#%d (1) { 68 ["value"]=> 69 NULL 70 } 71} 72