#33117 [NEW]: sqlite_last_error returns always 1 in case of error
| From: | stephaneey at hotmail dot com | Date: | Tue, 24 May 2005 07:08:37 +0000 |
| Subject: | #33117 [NEW]: sqlite_last_error returns always 1 in case of error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-79416@lists.php.net to get a copy of this message | ||
From: stephaneey at hotmail dot com
Operating system: windows & Linux
PHP version: 5.0.4
PHP Bug Type: SQLite related
Bug description: sqlite_last_error returns always 1 in case of error
Description:
------------
Hello,
sqlite_last_error() is supposed to return the error code from SQLite when
a SQL statement fails. In case of error, this function returns always 1.
So if you do
echo sqlite_error_string(sqlite_last_error()); you always get the same
error message description which is:
SQL logic error or missing database. The method "lastError()" of the super
class SQLiteDatabase behaves the same way!
This is very annoying because you're warned about the error but you cannot
log it correctly in a log file for example nor applying a specific
treatment to a specific error
Reproduce code:
---------------
<?
/* Using procedural functions */
$db=sqlite_open('testdb.db');
sqlite_exec('CREATE TABLE a_table(a_col);');
//Creation of a faulty statement
sqlite_exec($db,'INSERT INTO invalid_table VALUES(\'a_value\');') or
showError(sqlite_last_error($db));
/*This should return:
no such table : invalid_table...
*/
/*Generation of another error*/
sqlite_query($db,'SELECT b_col FROM a_table;') or
showError(sqlite_last_error($db));
/* This should return
no such column: b_column...
*/
function showError($err_code)
{
echo sqlite_error_string($err_code);
//Will always result in "SQL logic error or missing..."
}
?>
Expected result:
----------------
As mentionned in the code itself, I'd expect to get an appropriate error
code in order to :
- Log the errors correctly in an error file
- In case of exceptions handling, take the appropriate action according to
the last error
Actual result:
--------------
Bad error code returned since it's always the same no matter of what the
real error is!
--
Edit bug report at http://bugs.php.net/?id=33117&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33117&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33117&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33117&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33117&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33117&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33117&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33117&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33117&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33117&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33117&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33117&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33117&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33117&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33117&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33117&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33117&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33117&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33117&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33117&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33117&r=mysqlcfg