Bug #66950 [Com]: PDO::FETCH_OBJ fails with "Cannot access empty property"
| From: | cjames at me dot com | Date: | Thu, 11 Sep 2014 23:04:03 +0000 |
| Subject: | Bug #66950 [Com]: PDO::FETCH_OBJ fails with "Cannot access empty property" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187523@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66950&edit=1
ID: 66950
Comment by: cjames at me dot com
Reported by: mike at oobak dot org
Summary: PDO::FETCH_OBJ fails with "Cannot access empty
property"
Status: Open
Type: Bug
Package: PDO ODBC
Operating System: Red Hat Enterprise Linux 6.3
PHP Version: 5.5.10
Block user comment: N
Private report: N
New Comment:
My understanding was that the Teradata ODBC driver is based on DataDirect, therefore will never have
this functionality. The standard odbc* functions work because you've compiled with UnixODBC
Support, but PDO pulls the methods from the driver directly, which DataDirect does not support.
Previous Comments:
------------------------------------------------------------------------
[2014-03-24 21:08:46] mike at oobak dot org
configure line:
./configure --prefix=/dsap/opt/php-5.5.10 --enable-debug --with-pic --disable-rpath --disable-cgi
--with-libdir=lib64 --with-bz2 --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr
--enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr
--with-openssl --with-zlib --with-layout=PHP --enable-exif --enable-ftp --enable-magic-quotes
--with-mcrypt=shared,/usr --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg
--with-kerberos --enable-shmop --enable-calendar --without-sqlite --with-libxml-dir=/usr
--enable-xml --enable-pcntl --with-onig=/usr --enable-mbstring=shared --enable-maintainer-zts
--enable-zend-multibyte --disable-inline-optimization --enable-mbregex --with-gd=shared
--enable-bcmath=shared --enable-dba=shared --with-db4=/usr --with-xmlrpc=shared --with-ldap=shared
--enable-mysqlnd --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --enable-dom=shared
--enable-wddx=shared --enable-soap=shared --w!
ith-xsl=shared,/usr --enable-xmlreader=shared --enable-xmlwriter=shared --with-curl=shared,/usr
--with-unixODBC=shared,/usr --enable-pdo=shared --with-pdo-odbc=shared,unixODBC,/usr
--with-pdo-mysql=shared,mysqlnd --with-pdo-sqlite=shared,/usr --with-sqlite3=shared,/usr
--enable-json=shared --enable-zip=shared --without-readline --with-libedit --with-pspell=shared
--enable-phar=shared --with-tidy=shared,/usr --enable-sysvmsg=shared --enable-sysvshm=shared
--enable-sysvsem=shared --enable-posix=shared --enable-fileinfo=shared --enable-intl=shared
--with-icu-dir=/usr --with-enchant=shared,/usr --with-recode=shared,/usr --with-pear
--with-apxs2=/opt/ers400/apache2.2-64/bin/apxs
------------------------------------------------------------------------
[2014-03-24 21:01:58] mike at oobak dot org
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 this bug report at https://bugs.php.net/bug.php?id=66950&edit=1