Bug #55291 [Opn->Bgs]: All ODBC Queries Return INTs as Strings For Multiple ODBC Drivers
| From: | ssufficool@php.net | Date: | Thu, 01 Dec 2011 05:35:08 +0000 |
| Subject: | Bug #55291 [Opn->Bgs]: All ODBC Queries Return INTs as Strings For Multiple ODBC Drivers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165603@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55291&edit=1
ID: 55291
Updated by: ssufficool@php.net
Reported by: brandonkirsch at gmail dot com
Summary: All ODBC Queries Return INTs as Strings For Multiple
ODBC Drivers
-Status: Open
+Status: Bogus
Type: Bug
Package: ODBC related
Operating System: SUSE SLES 10 SP2
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Most database layers convert numeric values to strings to preserve their precision as PHP does not
support all numeric precisions which a database might (i.e. 64 bit integers). Since strings may be
silently converted to numeric in PHP ("1" + 2 = 3), this should not pose too much of an
issue.
Previous Comments:
------------------------------------------------------------------------
[2011-07-26 21:44:49] brandonkirsch at gmail dot com
Description:
------------
odbc_* and PDO ODBC functions are each returning SQL integer values as PHP
strings. However, SQL NULL values properly appear as PHP NULL values.
I have tested against multiple ODBC providers (FreeTDS and iSeries Access for
Linux).
System:
SUSE Enterprise Linux Server 10 (SP2) - 32bit
Linux dev-webhost1 2.6.16.60-0.42.5-default #1 Mon Aug 24 09:41:41 UTC 2009 i686
i686 i386 GNU/Linux
UnixODBC
PHP 5.3.6 from source
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-
mssql=/usr/local/freetds --with-ldap --prefix=/usr/local/php5 --with-config-
file-
path=/usr/local/php5/etc --enable-sockets --enable-soap --with-openssl --with-
unixODBC=/usr --with-gd --with-jpeg-dir=/usr/lib --with-pdo-odbc=unixODBC,/usr
Test script:
---------------
1. odbc_* against FreeTDS to SQL Server 2008:
$odbc = odbc_connect('hpsql3','--censored--','--censored--');
$or = odbc_exec($odbc,'SELECT 1');
var_dump(odbc_fetch_array($or)); // array( string "1" )
2. odbc_* against iSeries Access for Linux to AS/400:
$odbc = odbc_connect('iSeriesDSN','--','--');
$or = odbc_exec($odbc,'SELECT 1 FROM SYSIBM.SYSDUMMY1');
var_dump(odbc_fetch_array($or)); // array( string "1" )
3. PDO against FreeTDS to SQL Server 2008
$pdo = new PDO('odbc:hpsql3','--','--');
var_dump($pdo->query('SELECT 1')->fetch(PDO::FETCH_ASSOC)); // array (string
"1")
4. PDO against iSeries Access for Linux to AS/400
$pdo = new PDO('odbc:iSeriesDSN','--','--');
var_dump($pdo->query('SELECT 1 FROM SYSIBM.SYSDUMMY1')->fetch(PDO::FETCH_ASSOC)); //
array (string "1")
Expected result:
----------------
I expect to get arrays containing (int) 1
Actual result:
--------------
I actually get arrays containing (string) "1"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55291&edit=1