|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-12-30 05:18 UTC] hugo dot pl at gmail dot com
[2004-12-30 05:29 UTC] hugo dot pl at gmail dot com
[2004-12-31 01:31 UTC] iliaa@php.net
[2005-01-01 14:27 UTC] helly@php.net
[2005-01-10 00:25 UTC] hugo dot pl at gmail dot com
[2005-01-10 08:46 UTC] helly@php.net
[2005-01-11 04:27 UTC] hugo dot pl at gmail dot com
[2010-05-03 15:59 UTC] johannes@php.net
-Status: Open
+Status: Bogus
-Package: Feature/Change Request
+Package: *General Issues
[2010-05-03 15:59 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 17:00:01 2025 UTC |
Description: ------------ Hi, (english is not my natural language) I'm sending a patch to SQLite module (is here the right place to do it?). It's add Exceptions to OO interface of SQLite module when a error occur executing a query. Affected methods: query() singleQuery() unbufferedQuery() arrayQuery() If any error occur when executing the query a exception of type SQLiteException is throw. The message of the exeception is the same returned from SQLite, library (description of the sql error). I made this patch because I'm doing a frontend to SQLite and I need descriptive message about errors on SQL queries and I can't find how to catch the query syntax error messages trowed by SQLite library (actually this messages are only show in warning messages). Ex.: If a do the query: $db->query("SELECT FROM anytable"); I cant catch the SQLite message saying that exists a syntax error near "FROM anytable"... with tha actual interface I can get only the generic message "SQL logic error or missing database" returned by sqlite_error_string(sqlite_last_error()). I think that the function sqlite_last_error() should return a error string like mysql_error(), not a error code, because the error string returned by sqlite_error_string is not too usefull, I'm send the fle ext/sqlite/sqlite.c with modification based on PHP-5.0.2, if anyone accept this patch, nice, will be my first patch, otherwise I wish at least hear another ideia to solve the "problem". Reproduce code: --------------- <pre> <?php // Patch test-case // our bugged query $query = 'SELASDF sdaF SDaf '; // Test OO interface (all *query methods must trow a exception) $db = new SQLiteDatabase("teste.db"); $aMethods = array('query', 'singleQuery', 'unbufferedQuery', 'arrayQuery'); $n = count($aMethods); echo "Testing OO interface...\n"; foreach ($aMethods as $method) { try { eval('@$db->'.$method.'($query);'); echo '$db::', $method, "(); // fail!\n"; } catch (SQLiteException $e) { echo '$db::', $method, "(); // Ok!\n"; } try { eval('$r = @$db->'.$method.'($query);'); echo '$r = $db::', $method, "(); // fail!\n"; } catch (SQLiteException $e) { echo '$r = $db::', $method, "(); // Ok!\n"; } } echo "All done.... :)\n"; ?> Expected result: ---------------- Testing OO interface... $db::query(); // Ok! $r = $db::query(); // Ok! $db::singleQuery(); // Ok! $r = $db::singleQuery(); // Ok! $db::unbufferedQuery(); // Ok! $r = $db::unbufferedQuery(); // Ok! $db::arrayQuery(); // Ok! $r = $db::arrayQuery(); // Ok! All done.... :) Actual result: -------------- Testing OO interface... $db::query(); // fail! $r = $db::query(); // fail! $db::singleQuery(); // fail! $r = $db::singleQuery(); // fail! $db::unbufferedQuery(); // fail! $r = $db::unbufferedQuery(); // fail! $db::arrayQuery(); // fail! $r = $db::arrayQuery(); // fail! All done.... :)