php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61101 Fetch Class does not set the column name
Submitted: 2012-02-16 04:42 UTC Modified: 2013-02-18 00:35 UTC
From: anilvarghese25 at gmail dot com Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.3.10 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anilvarghese25 at gmail dot com
New email:
PHP Version: OS:

 

 [2012-02-16 04:42 UTC] anilvarghese25 at gmail dot com
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'

Patches

pdostatement_fetch_class_fix (last revision 2012-02-16 04:43 UTC by anilvarghese25 at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-14 20:11 UTC] iliaa@php.net
-Status: Open +Status: Feedback
 [2012-03-14 20:11 UTC] iliaa@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Cannot reproduce the issue even with PHP 5.3.8
 [2012-03-14 20:14 UTC] anilvarghese25 at gmail dot com
I was using 5.3.10. Might be a new bug? 

My patch fixed the issue and its being used in our production environment now.
 [2012-03-14 20:17 UTC] anilvarghese25 at gmail dot com
Have to also add, SQLDescribeParameter call seems to fail for me. Could this be 
the reason the namelen is not set?
 [2013-01-04 21:48 UTC] anilvarghese25 at gmail dot com
I attempted to upgrade my application to php 5.4.10. This issue still persists.
I am using unixodbc and freetds to connect to mssql db.
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 [2013-10-17 16:00 UTC] anilvarghese25 at gmail dot com
I am using unixodbc with freetds to connect to mssql. PHP version 5.3.10 and red hat. I have tested the same with newer versions and the problem still persists. Could you please look into this? Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 19:01:28 2024 UTC