Re: DB errorNative() method
| From: | Mika Tuupola | Date: | Wed, 07 Jan 2004 14:28:17 +0000 |
| Subject: | Re: DB errorNative() method | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-24848@lists.php.net to get a copy of this message | ||
On Wed, 7 Jan 2004, Bertrand Mansion wrote:
> I think sqlite returns error codes.
> http://fr.php.net/manual/en/function.sqlite-last-error.php
Well I should have said "meaningfull". sqlite_last_error()
only returns 1 for for SQL related errors. Its a limitation of
libsqlite. For example try this code:
-cut-
ini_set('track_errors', true);
$conn = sqlite_open('./test.db');
$result = sqlite_query('SELECT * FROM nosuch', $conn);
print '$php_errormsg = ' . "$php_errormsg \n";
print 'sqlite_last_error($conn) = ' . sqlite_last_error($conn) . "\n";
print 'sqlite_error_string(sqlite_last_error($conn)) = ' .
sqlite_error_string(s
qlite_last_error($conn)) . "\n";
-cut-
the output will be:
-cut-
$php_errormsg = no such table: nosuch
sqlite_last_error($conn) = 1
sqlite_error_string(sqlite_last_error($conn)) = SQL logic error or missing
database
-cut-
So you can only get usefull error messages by using
track_errors and php_errormsg but not sqlite_last_error().
--
Mika Tuupola http://www.appelsiini.net/~tuupola/