1--TEST-- 2PDO Common: Bug #44409 (PDO::FETCH_SERIALIZE calls __construct()) 3--SKIPIF-- 4<?php # vim:ft=php 5if (!extension_loaded('pdo')) die('skip'); 6$dir = getenv('REDIR_TEST_DIR'); 7if (false == $dir) die('skip no driver'); 8require_once $dir . 'pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); 14require getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 15$db = PDOTest::factory(); 16 17$db->exec("CREATE TABLE test (dat varchar(100))"); 18$db->exec("INSERT INTO test (dat) VALUES ('Data from DB')"); 19 20class bug44409 implements Serializable 21{ 22 public function __construct() 23 { 24 printf("Method called: %s()\n", __METHOD__); 25 } 26 27 public function serialize() 28 { 29 return "any data from serizalize()"; 30 } 31 32 public function unserialize($dat) 33 { 34 printf("Method called: %s(%s)\n", __METHOD__, var_export($dat, true)); 35 } 36} 37 38$stmt = $db->query("SELECT * FROM test"); 39 40print_r($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, "bug44409")); 41 42?> 43--EXPECT-- 44Method called: bug44409::unserialize('Data from DB') 45Array 46( 47 [0] => bug44409 Object 48 ( 49 ) 50 51) 52