php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42632 PDO fetch doesn't preserve case
Submitted: 2007-09-11 21:31 UTC Modified: 2008-05-07 18:08 UTC
From: mattsch at gmail dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.4 OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mattsch at gmail dot com
New email:
PHP Version: OS:

 

 [2007-09-11 21:31 UTC] mattsch at gmail dot com
Description:
------------
PDO fetch doesn't preserve the case of the column.  I don't know if this is a "feature" or if it is a bug, but if it is a "feature" since the beginning of PDO, could I also suggest that another flag be added for PDO fetch to tell it to preserve the case?



Reproduce code:
---------------
<?php
try {
$pdo = new PDO("pgsql:host={$host};dbname={$database}", $user, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->query("SET search_path to {$schema}");
$accountState = $pdo->prepare('
	SELECT id AS accountId
	FROM account
	WHERE id = ?
');
$accountState->bindParam(1, $id, PDO::PARAM_INT);
$accountState->execute();
$getAccount = $accountState->fetch(PDO::FETCH_OBJ);
$accountState->closeCursor();
var_dump($getAccount);
} catch (Exception $e){
print "An error occurred: {$e->getMessage()}";
}
?>

Expected result:
----------------
object(stdClass)#8 (1) {
  ["accountId"]=>
  int(339)
}


Actual result:
--------------
object(stdClass)#8 (1) {
  ["accountid"]=>
  int(339)
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-07 18:08 UTC] lsmith@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected behavior. The SQL standard mandates that identifiers 
are not case sensitive and that all unquoted identifiers be returned in 
upper case. However this is a question of the underlying client API. In 
the case of PostgreSQL the developers deliberately decided to return identifiers lower case by default. You can force a specific case (though 
not mixed case or case preserving) via a connection/statement level 
attribute. Check the documentation.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC