Edit report at http://bugs.php.net/bug.php?id=53466&edit=1
ID: 53466 Updated by: scott...@php.net Reported by: danielc at analysisandsolutions dot com Summary: sqlite3 columnType() returns SQLITE3_NULL when not in fetch loop -Status: Open +Status: Closed Type: Feature/Change Request Package: SQLite related Operating System: linux PHP Version: 5.3SVN-2010-12-03 (SVN) -Assigned To: +Assigned To: scottmac Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-01-06 01:09:01] scott...@php.net Automatic comment from SVN on behalf of scottmac Revision: http://svn.php.net/viewvc/?view=revision&revision=307143 Log: Implemented FR #53466 (SQLite3Result::columnType() should return false after all of the rows have been fetched). ------------------------------------------------------------------------ [2010-12-03 18:28:15] danielc at analysisandsolutions dot com Description: ------------ The SQLite3Result::columnType() method returns SQLITE3_NULL (5) if not looping over results. This is done because the data type is unknown. But this leads to confusion, because SQLITE3_NULL is a legitimate answer in some cases when inside the loop. It would be clearer if PHP returned NULL or FALSE instead. Test script: --------------- $db = new SQLite3(':memory:'); $db->exec('CREATE TABLE test (whatever INTEGER)'); $db->exec('INSERT INTO test (whatever) VALUES (1)'); $result = $db->query('SELECT * FROM test'); while ($row = $result->fetchArray(SQLITE3_NUM)) { var_dump($result->columnType(0)); // int(1) [SQLITE3_INTEGER] } // Seems returning null or false is more appropriate. var_dump($result->columnType(0)); // int(5) [SQLITE3_NULL] $result->finalize(); $db->close(); echo "Done\n"; Expected result: ---------------- int(1) bool(false) Done Actual result: -------------- int(1) int(5) Done ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53466&edit=1