Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18658 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66871 invoked by uid 1010); 2 Sep 2005 18:35:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 66855 invoked from network); 2 Sep 2005 18:35:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2005 18:35:19 -0000 X-Host-Fingerprint: 212.55.154.25 relay5.ptmail.sapo.pt Linux 2.4/2.6 Received: from ([212.55.154.25:51449] helo=sapo.pt) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 40/F9-15098-56B98134 for ; Fri, 02 Sep 2005 14:35:17 -0400 Received: (qmail 2178 invoked from network); 2 Sep 2005 18:35:13 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.157) by relay5 with SMTP; 2 Sep 2005 18:35:13 -0000 Received: (qmail 27850 invoked from network); 2 Sep 2005 18:35:12 -0000 X-AntiVirus: PTMail-AV 0.3-0.86.2 Received: from unknown (HELO pc07653) (nunoplopes@sapo.pt@[81.193.153.214]) (envelope-sender ) by mta7 (qmail-ldap-1.03) with SMTP for ; 2 Sep 2005 18:35:12 -0000 Message-ID: <010901c5afed$0db28380$0100a8c0@pc07653> To: "Ilia Alshanetsky" Cc: "PHPdev" References: <010101c5afea$4227cd80$0100a8c0@pc07653> <43189886.4010500@prohost.org> Date: Fri, 2 Sep 2005 19:35:11 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Subject: Re: [PHP-DEV] [PATCH] sqlite: retrieve SQL syntax errors From: nlopess@php.net ("Nuno Lopes") OK, I probably didn't explain the problem well. So let me separate the problems: the bug: prints: Notice: Undefined variable: errstr in /cvs/php-src/sqlite.php on line 2 Notice: Undefined variable: errstr in /cvs/php-src/sqlite.php on line 3 ----- the "feature request": prints "SQL logic error or missing database", but you don't have a clue of what error is. with my patch, you can retrieve the error (in the additional variable) you get in the Warning message ("no such column: column"). Nuno ----- Original 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).