Bug #66950 [NEW]: PDO::FETCH_OBJ fails with "Cannot access empty property"
| From: | mike at oobak dot org | Date: | Mon, 24 Mar 2014 21:01:59 +0000 |
| Subject: | Bug #66950 [NEW]: PDO::FETCH_OBJ fails with "Cannot access empty property" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184870@lists.php.net to get a copy of this message | ||
From: mike at oobak dot org
Operating system: Red Hat Enterprise Linux 6.3
PHP version: 5.5.10
Package: PDO ODBC
Bug Type: Bug
Bug description:PDO::FETCH_OBJ fails with "Cannot access empty property"
Description:
------------
PHP 5.5.10
unixODBC 2.3.2
tdodbc (Teradata ODBC driver) 14.10
Attempts to use PDO::FETCH_OBJ and PDO::FETCH_CLASS fail with the error
"Cannot access empty property." Switching to PDO::FETCH_LAZY shows a
blank field name (see below). Other methods such as PDO::FETCH_NAMED and
PDO::FETCH_ASSOC work fine.
Plain vanilla odbc_fetch_obj() (without PDO) works fine.
PDO::FETCH_OBJ works fine with a different ODBC driver.
pdo_odbc / Teradata / PDO::FETCH_OBJ => fails
pdo_odbc / Teradata / PDO::FETCH_CLASS => fails
pdo_odbc / Teradata / PDO::FETCH_NAMED => succeeds
pdo_odbc / Oracle / PDO::FETCH_OBJ => succeeds
odbc / Teradata / odbc_fetch_obj() => succeeds
Test script:
---------------
$dbh = new PDO("odbc:FOO");
$sth = $dbh->query("
SELECT rolename
FROM dbc.allrolerights
WHERE databasename = 'BAR'
");
$result = $sth->fetch(PDO::FETCH_OBJ);
Expected result:
----------------
object(stdClass)#1 (1) {
["RoleName"]=>
string(30) "FNAR "
}
Actual result:
--------------
PDO::FETCH_OBJ or PDO::FETCH_CLASS (with stdClass or user class):
PHP Fatal error: Cannot access empty property
PDO::FETCH_LAZY:
object(PDORow)#3 (2) {
["queryString"]=>
string(95) "
SELECT rolename
FROM dbc.allrolerights
WHERE databasename = 'BAR'
"
[""]=>
string(30) "FNAR "
}
PDO::FETCH_NAMED:
array(1) {
["RoleName"]=>
string(30) "FNAR "
}
My stack thread:
http://stackoverflow.com/questions/22614222/pdo-returning-empty-property-name
--
Edit bug report at https://bugs.php.net/bug.php?id=66950&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66950&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66950&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66950&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66950&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66950&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66950&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66950&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66950&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66950&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66950&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66950&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66950&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66950&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66950&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66950&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66950&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66950&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66950&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66950&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66950&r=mysqlcfg