Edit report at https://bugs.php.net/bug.php?id=55291&edit=1
ID: 55291 Comment by: martijntje at martijnotto dot nl Reported by: brandonkirsch at gmail dot com Summary: All ODBC Queries Return INTs as Strings For Multiple ODBC Drivers Status: Not a bug 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: I have no idea why this bug is closed as bogus. The current behavior is wrong for many reasons: - Higher memory usage (can be problematic with big datasets) - This forces one to use is_numeric instead of is_int, is_float, etc (much slower) - Removed the option for strict comparison: "1" === 1 => false Previous Comments: ------------------------------------------------------------------------ [2011-12-01 05:35:08] ssuffic...@php.net 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. ------------------------------------------------------------------------ [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