Bug #61101 [NEW]: Fetch Class does not set the column name

From: Date: Thu, 16 Feb 2012 04:42:58 +0000
Subject: Bug #61101 [NEW]: Fetch Class does not set the column name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-167562@lists.php.net to get a copy of this message
From:             
Operating system: Linux
PHP version:      5.3.10
Package:          PDO related
Bug Type:         Bug
Bug description:Fetch Class does not set the column name

Description:
------------
PDOStatement::Fetch using PDO::FETCH_CLASS does not set the attribute name.
The class set function is called with an empty var name but correct
variable value.

Test script:
---------------
$connection = new PDO($dsn, $user, $password);
$sql = 'select 1 as columnname from table where 1 = :value';
$stmt = $connection->prepare($sql);
$stmt->bindValue(':value', 1);
$result = $stmt->execute();
$class = $stmt->fetchAll(PDO::FETCH_CLASS, 'Test');

Expected result:
----------------
Will get an array of class Test with property '' and value 1.



Actual result:
--------------
Expect to see column name as 'columnname'

-- 
Edit bug report at https://bugs.php.net/bug.php?id=61101&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=61101&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=61101&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=61101&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=61101&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61101&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=61101&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=61101&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=61101&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=61101&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=61101&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=61101&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=61101&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=61101&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=61101&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=61101&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61101&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=61101&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=61101&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=61101&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=61101&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=61101&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#167562) next »