|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53466 sqlite3 columnType() returns SQLITE3_NULL when not in fetch loop
Submitted: 2010-12-03 18:28 UTC Modified: 2011-01-06 01:11 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: danielc at analysisandsolutions dot com Assigned: scottmac
Status: Closed Package: SQLite related
PHP Version: 5.3SVN-2010-12-03 (SVN) OS: linux
Private report: No CVE-ID:
 [2010-12-03 18:28 UTC] danielc at analysisandsolutions dot com
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]


echo "Done\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-06 01:09 UTC]
Automatic comment from SVN on behalf of scottmac
Log: Implemented FR #53466 (SQLite3Result::columnType() should return false after all of the rows have been fetched).
 [2011-01-06 01:11 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: scottmac
 [2011-01-06 01:11 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 18:01:30 2015 UTC