Edit report at http://bugs.php.net/bug.php?id=52295&edit=1

 ID:               52295
 Updated by:       johan...@php.net
 Reported by:      parke dot bostrom at gmail dot com
 Summary:          SQLite's PDO fetch converts integers, reals to strings
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          SQLite related
 Operating System: Linux
 PHP Version:      5.3.2

 New Comment:

SQLite stores all data as string. As PHP is dynamically typed we don't
have a reason to do the conversion as it is done when needed and would
just cost performance,


Previous Comments:
------------------------------------------------------------------------
[2010-07-09 00:27:05] parke dot bostrom at gmail dot com

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 this bug report at http://bugs.php.net/bug.php?id=52295&edit=1

Reply via email to