php.net |  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: 2020-10-11 04:22 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mike at oobak dot org Assigned: cmb (profile)
Status: No Feedback Package: PDO ODBC
PHP Version: 5.5.10 OS: Red Hat Enterprise Linux 6.3
Private report: No CVE-ID: None
 [2014-03-24 21:01 UTC] 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

Patches

Pull Requests

History

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.
 [2020-09-28 14:13 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-09-28 14:13 UTC] cmb@php.net
Can anybody reproduce this with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2020-10-11 04:22 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 "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 09:01:27 2024 UTC