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