From:
Operating system: Linux
PHP version: 5.3.2
Package: SQLite related
Bug Type: Bug
Bug description:SQLite's PDO fetch converts integers, reals to strings
Description:
------------
When you select and fetch integers and reals from an SQLite database, they
are returned as strings. Why? I would prefer that when I fetch an integer
(or a float), the SQLite PDO driver give me an integer (or a float) rather
than converting everything to a string (which is annoying). Thanks!
Test script:
---------------
<?php
$pdo = new PDO ('sqlite::memory:');
// $select = $pdo->query ('select 5 as foo, typeof (5) as bar;');
$select = $pdo->query ('select 5.0 as foo, typeof (5.0) as bar;');
$row = $select->fetch (PDO::FETCH_ASSOC);
print "actual result:\n";
var_dump ($row);
print "\n";
print "expected result:\n";
$row['foo'] = (float) 5.0;
var_dump ($row);
?>
Expected result:
----------------
array(2) {
["foo"]=>
float(5)
["bar"]=>
string(4) "real"
}
Actual result:
--------------
array(2) {
["foo"]=>
string(3) "5.0"
["bar"]=>
string(4) "real"
}
--
Edit bug report at http://bugs.php.net/bug.php?id=52295&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52295&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52295&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52295&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52295&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52295&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52295&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52295&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52295&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52295&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52295&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52295&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52295&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52295&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52295&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52295&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52295&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52295&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52295&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52295&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52295&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52295&r=mysqlcfg