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__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 8MySQLPDOTest::skip(); 9?> 10--FILE-- 11<?php 12 13 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 14 $pdoDb = MySQLPDOTest::factory(); 15 16 17 class myclass { 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('DROP TABLE IF EXISTS testz'); 29 30 $pdoDb->query('CREATE TABLE testz (name VARCHAR(20) NOT NULL, value INT)'); 31 32 $pdoDb->query("INSERT INTO testz VALUES ('myclass', 1), ('myclass2', 2), ('myclass', NULL), ('myclass3', NULL)"); 33 34 $stmt = $pdoDb->prepare("SELECT * FROM testz"); 35 36 var_dump($stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_GROUP)); 37 $stmt->execute(); 38 39 var_dump($stmt->fetch()); 40 var_dump($stmt->fetch()); 41 var_dump($stmt->fetchAll()); 42?> 43--CLEAN-- 44<?php 45require __DIR__ . '/mysql_pdo_test.inc'; 46$db = MySQLPDOTest::factory(); 47$db->exec('DROP TABLE IF EXISTS testz'); 48?> 49--EXPECTF-- 50bool(true) 51myclass::__construct() 52object(myclass)#%d (1) { 53 ["value"]=> 54 string(1) "1" 55} 56myclass::__construct() 57object(myclass2)#%d (1) { 58 ["value"]=> 59 string(1) "2" 60} 61myclass::__construct() 62array(2) { 63 [0]=> 64 object(myclass)#%d (1) { 65 ["value"]=> 66 NULL 67 } 68 [1]=> 69 object(stdClass)#%d (1) { 70 ["value"]=> 71 NULL 72 } 73} 74