|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66950 PDO::FETCH_OBJ fails with "Cannot access empty property"
Submitted: 2014-03-24 21:01 UTC Modified: -
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mike at oobak dot org Assigned:
Status: Open Package: PDO ODBC
PHP Version: 5.5.10 OS: Red Hat Enterprise Linux 6.3
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.
Block user comment
Status: Assign to:
Bug Type:
From: mike at oobak dot org
New email:
PHP Version: OS:


 [2014-03-24 21:01 UTC] mike at oobak dot org
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) {
  string(30) "FNAR                          "

Actual result:
PDO::FETCH_OBJ or PDO::FETCH_CLASS (with stdClass or user class):

PHP Fatal error:  Cannot access empty property


object(PDORow)#3 (2) {
  string(95) "
  SELECT rolename
  FROM dbc.allrolerights
  WHERE databasename = 'BAR'
  string(30) "FNAR                          "


array(1) {
  string(30) "FNAR                          "

My stack thread:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-24 21:08 UTC] 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 --with-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-09-11 23:04 UTC] cjames at me dot com
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.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC