Home » Database » MDB2 » Bug #8211
queryAll lowercases key names if returning assoc
Details
| Submitted | 2006-07-13 17:02 UTC |
|---|---|
| From | dabrfe at gmail dot com |
| Assigned | quipo |
| Status | Bogus |
| Package | MDB2 |
| PHP Version | 5.1.4 |
| OS | OS X 10.4.7 |
| Roadmaps | (Not assigned) |
Comments
[2006-07-13 17:02 UTC] dabrfe at gmail dot com
Description:
------------
If a MySQL db is set up with caps in the field names and the
code selects these fields capitalized and retrieves using
queryAll or queryRow with MDB2_FETCHMODE_ASSOC, the keys in
the returned array are all lowercased.
MDB2 2.1.0 stable
MDB2_Driver_mysql 1.1.0 stable
PEAR 1.4.9 stable
PHP installed using package from entropy.ch.
Configure Command => './configure' '--prefix=/usr/local/
php5' '--with-apxs' '--with-config-file-scan-dir=/usr/local/
php5/php.d' '--with-iconv' '--with-openssl=/usr' '--with-
zlib=/usr' '--with-gd' '--with-zlib-dir=/usr' '--with-ldap'
'--with-xmlrpc' '--with-iconv-dir=/usr' '--enable-exif' '--
enable-wddx' '--enable-soap' '--enable-sqlite-utf8' '--
enable-ftp' '--enable-sockets' '--enable-dbx' '--enable-
dbase' '--enable-mbstring' '--enable-calendar' '--enable-
bcmath' '--with-bz2=/usr' '--with-curl=shared,/usr/local/
php5' '--with-mysql=shared,/usr/local/php5' '--with-
mysqli=shared,/usr/local/php5/bin/mysql_config' '--with-pdo-
mysql=shared,/usr/local/php5' '--with-libxml-dir=shared,/
usr/local/php5' '--with-xsl=shared,/usr/local/php5' '--with-
pdflib=shared,/usr/local/php5' '--with-
oci8=shared,instantclient,/usr/local/php5/oracle' '--with-
pdo-oci=shared,instantclient,/usr/local/php5/oracle,
10.1.0.3' '--with-imap=../imap-2004g' '--with-kerberos=/usr'
'--with-imap-ssl=/usr' '--with-jpeg-dir=/usr/local/php5' '--
with-png-dir=/usr/local/php5' '--enable-gd-native-ttf' '--
with-freetype-dir=/usr/local/php5' '--with-iodbc=shared,/
usr' '--with-pgsql=shared,/usr/local/php5' '--with-pdo-
pgsql=shared,/usr/local/php5' '--with-t1lib=/usr/local/php5'
'--with-gettext=shared,/usr/local/php5' '--with-
ming=shared,/usr/local/php5' '--with-mcrypt=shared,/usr/
local/php5' '--with-mhash=shared,/usr/local/php5' '--with-
mssql=shared,/usr/local/php5' '--with-fbsql=shared,/Users/
liyanage/svn/entropy/universalbuild/src/
FBDeveloperLibraries/Library/FrontBase' '--with-json=shared'
Test script:
---------------
SQL:
CREATE TABLE reporttypes (
ReportTypeID smallint(6) NOT NULL,
ReportTypeDesc varchar(50) NOT NULL,
FormTypeID smallint(6) NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
<?
require_once('MDB2.php');
$DB=MDB2::connect('mysql://....');
$DB->setFetchMode(MDB2_FETCHMODE_ASSOC);
$sql="select ReportTypeID, ReportTypeDesc, FormTypeID from reporttypes";
$results=$DB->queryRow($sql);
print_r($results);
?>
Expected result:
----------------
Array
(
[ReportTypeID] => 1
[ReportTypeDesc] => Full Text Description
[FormTypeID] => 1
)
Actual result:
--------------
Array
(
[reporttypeid] => 1
[reporttypedesc] => Full Text Description
[formtypeid] => 1
)
[2006-07-13 19:20 UTC] dabrfe at gmail dot com
Suggest you update the manual. MDB2_PORTABILITY_LOWERCASE is
not listed as a constant. Only mentioned in the examples. Nor
is that constant listed in http://pear.php.net/package/MDB2/
docs/2.1.0/MDB2/_MDB2-2.1.0_MDB2_php.html.
[2006-07-13 19:28 UTC] dabrfe at gmail dot com
Still does not work. In fact, the MDB2_PORTABILITY_LOWERCASE
constant does not appear to be defined:
<?
require_once('MDB2.php');
$DB=MDB2::connect('mysql://...');
$DB->setFetchMode(MDB2_FETCHMODE_ASSOC);
$DB->setOption('portability', MDB2_PORTABILITY_ALL ^
MDB2_PORTABILITY_LOWERCASE);
$sql="select ReportTypeID, ReportTypeDesc, FormTypeID
from reporttypes";
$results=$DB->queryRow($sql);
print_r($results);
print MDB2_PORTABILITY_ALL . ' - ' .
MDB2_PORTABILITY_LOWERCASE;
?>
Output:
Array
(
[reporttypeid] => 1
[reporttypedesc] => Full Text Description
[formtypeid] => 1
)
127 - MDB2_PORTABILITY_LOWERCASE