From: maximkh at yahoo dot com Operating system: Linux PHP version: 5.1.4 PHP Bug Type: Feature/Change Request Bug description: Requesting proper data-type support for PDO_SQLITE
Description: ------------ Hello, I was going through the source for PDO_SQLITE extension, and it looks to me as though the only supported data types are text and null. The native types for SQLite such as INTEGER, REAL, and BLOB are all converted into strings, which not only take up more space, but also take away one of the advantages of SQLite, namely being able to store different data types in the same column. Given that SQLite doesnt even have column types, this kind of implementation effectively takes away all data-type support altogether. We can use various is_* functions and convert the data ourselves, but that only solves half the problem. If the data is stored in the database as strings, it still takes up a lot more space than it needs to (with ints, and reals). In addition, if BLOB data is converted into utf-8 strings or similar, storing binary data might prove to be a problem, though I havent looked into this one yet. Would like to request added support for native SQLite data-types if possible. Reproduce code: --------------- @unlink('example.db'); $db = new PDO('sqlite:example.db'); $db->query('CREATE TABLE my_table (my_column BLOB NULL)'); $db->query('INSERT INTO my_table VALUES (\'text\')'); $db->query('INSERT INTO my_table VALUES (123)'); $db->query('INSERT INTO my_table VALUES (123.45)'); $db->query('INSERT INTO my_table VALUES (NULL)'); $result = $db->query('SELECT * FROM my_table'); foreach ($result as $row) var_dump($row['my_column'])."\n"; Expected result: ---------------- string(4) "text" int(123) float(123.45) NULL Actual result: -------------- string(4) "text" string(3) "123" string(6) "123.45" NULL -- Edit bug report at http://bugs.php.net/?id=38334&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38334&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38334&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38334&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38334&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38334&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38334&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38334&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38334&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38334&r=support Expected behavior: http://bugs.php.net/fix.php?id=38334&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38334&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38334&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38334&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38334&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38334&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38334&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38334&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38334&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38334&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38334&r=mysqlcfg