#44407 [Com]: When using FETCH_CLASS|CLASS_TYPE 'MyClass' an array of stdClass returned

From: Date: Mon, 12 May 2008 16:41:10 +0000
Subject: #44407 [Com]: When using FETCH_CLASS|CLASS_TYPE 'MyClass' an array of stdClass returned
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124915@lists.php.net to get a copy of this message
 ID:               44407
 Comment by:       ludmilla dot bogavac at vgregion dot se
 Reported By:      robert dot allen at zircote dot com
 Status:           Open
 Bug Type:         PDO related
 Operating System: Windows XP
 PHP Version:      5.2.5
 New Comment:

Server OS: Solaris 9, Database server: IBM Informix IDS 9.4, Web Server
Apache/2.0.54, PHP: 5.2.5, ODBC-driver: IBM Informix ODBC Driver
-------------------
Reproduce Code:

class MyBaseClass
{
	public $par1;
	private $par2;
	private $par3;
	public $par4;
}
class MyClass extends MyBaseClass 
{
	public $par5;
	public $par6;
	
	public function __construct($par1, $par4, $par5, $par6)
	{
		$this->par1 = $par1;
		$this->par2 = $par1;
		$this->par3 = $par4;
		$this->par4 = $par4;
		$this->par5 = $par5;
		$this->par6 = $par6;
	}	
}
		$db = new PDO("informix:connection string parameters", "user",
"password");
		$stmt = $db->prepare("EXECUTE PROCEDURE mystoredprocedure()");
		$stmt->setFetchMode(PDO::FETCH_CLASS,'MyClass');
		$stmt->execute();
		$result = $stmt->fetchAll(PDO::FETCH_CLASS);
		print_r($result);
		
----------------------
Expected result:
Array ( [0] => MyClass Object (...
------------------------------
Actual result:
Array ( [0] => stdClass Object (...


Previous Comments:
------------------------------------------------------------------------

[2008-03-11 16:00:06] robert dot allen at zircote dot com

Description:
------------
Windows XP / PHP 5.2.5 / PDO_ODBC

When setFetchMode is called with FETCH_CLASS and the Object type
specified the Object type is returned as stdClass in the array for
fetchAll() however for fetch() returns the expected result of the
defined object.




Reproduce code:
---------------
$stmt->setFetchMode(PDO :: FETCH_CLASS | PDO :: FETCH_CLASSTYPE,
'MyClass');
$stmt->execute();
$all = $stmt->fetchAll();



Expected result:
----------------
return:
Array ( [0] => MyClass Object (.....

Actual result:
--------------
return:
Array ( [0] => stdClass Object (.....


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44407&edit=1



Thread (2 messages)

« previous php.bugs (#124915) next »