Req #53466 [NEW]: sqlite3 columnType() returns SQLITE3_NULL when not in fetch loop
| From: | danielc at analysisandsolutions dot com | Date: | Fri, 03 Dec 2010 17:28:16 +0000 |
| Subject: | Req #53466 [NEW]: sqlite3 columnType() returns SQLITE3_NULL when not in fetch loop | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-156745@lists.php.net to get a copy of this message | ||
From:
Operating system: linux
PHP version: 5.3SVN-2010-12-03 (SVN)
Package: SQLite related
Bug Type: Feature/Change Request
Bug description:sqlite3 columnType() returns SQLITE3_NULL when not in fetch loop
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 bug report at http://bugs.php.net/bug.php?id=53466&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53466&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53466&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53466&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53466&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53466&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53466&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53466&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53466&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53466&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53466&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53466&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53466&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53466&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53466&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53466&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53466&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53466&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53466&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53466&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53466&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53466&r=mysqlcfg