|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52295 SQLite's PDO fetch converts integers, reals to strings
Submitted: 2010-07-09 00:27 UTC Modified: 2010-07-09 01:04 UTC
From: parke dot bostrom at gmail dot com Assigned:
Status: Not a bug Package: SQLite related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
34 - 16 = ?
Subscribe to this entry?

 [2010-07-09 00:27 UTC] parke dot bostrom at gmail dot com
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:

$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) {
  string(4) "real"

Actual result:
array(2) {
  string(3) "5.0"
  string(4) "real"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-09 01:04 UTC]
-Status: Open +Status: Bogus
 [2010-07-09 01:04 UTC]
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,
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 18:01:30 2024 UTC