Re: [PATCH] sqlite: retrieve SQL syntax errors
| From: | Ilia Alshanetsky | Date: | Fri, 02 Sep 2005 18:23:02 +0000 |
| Subject: | Re: [PATCH] sqlite: retrieve SQL syntax errors | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-18657@lists.php.net to get a copy of this message | ||
I've just tried to replicate the problem and it appears to work fine:
$db = sqlite_open(":memory:");
sqlite_exec($db, "SELECT ***");
var_dump(sqlite_error_string(sqlite_last_error($db)));
prints "SQL logic error or missing database"
Ilia
Nuno Lopes wrote:
> Hi,
>
> I've made a simple patch to allow a user to retrieve the SQL syntax
> error occured in either sqlite_exec(), sqlite_query() or
> sqlite_unbuffered_query().
> Untill now this wasn't possible, because sqlite_last_error() doesn't
> handle SQL syntax errors. The patch adds an additional parameter to
> those 3 functions (OO and non-OO versions) to retrieve the error.
>
> Patch: http://mega.ist.utl.pt/~ncpl/php_sqlite.txt
> Example:
> <?
> $idx = sqlite_open(':memory:');
> @sqlite_exec($idx, 'SELECT column', $error);
> echo $error;
> ?>
>
> I hope this can enter in PHP 5.1.0, as it is a fairly simple patch.
>
>
> Nuno
>
> P.S.: the patch also fixes a bug in the SQLiteDatabase constructor,
> where the $errorstr variable wasn't filled (because it wasn't beeing
> passed by reference).