Bug #1690 [Opn->Bgs]: PEAR::DB no catch query() error ? @mysql

From: Date: Mon, 21 Jun 2004 11:28:26 +0000
Subject: Bug #1690 [Opn->Bgs]: PEAR::DB no catch query() error ? @mysql
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-31017@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=1690&edit=1 ID: 1690 Updated by: cipri@php.net Reported By: donyad at 126 dot com -Status: Open +Status: Bogus Type: Bug Package: Bug System Operating System: WinXP PHP Version: 4.3.7 New Comment: Thank you for taking the time to write to us, but this is not a bug. > $result = $db->query('select ... desc'); > if(DB::isError($db)){ > die($db->getMessage()); >} You need to check if the returned value is a PEAR_Error, not the DB object itself. Replace $db with $result: if (DB::isError($result)) { Previous Comments: ------------------------------------------------------------------------ [2004-06-21 05:32:17] donyad at 126 dot com Description: ------------ when i query a wrong sql at mysql PEAR::DB do not report me sql error just PHP report me the next function was undefined ... the DB class just download today DB-1[1].6.4.tgz Reproduce code: --------------- $dsn = 'mysql://root:root@localhost/my_database'; $options = array( 'debug' => 2, 'portability' => DB_PORTABILITY_ALL, ); $db = DB::connect($dsn, $options); if(DB::isError($db)){ die($db->getMessage()); } $db->setFetchMode(DB_FETCHMODE_ASSOC); $result = $db->query('select * from my_table where hide=0 order by time desc'); if(DB::isError($db)){ die($db->getMessage()); } //my_table do not have time field //this sql is error //butPEAR() catch nothing ... Expected result: ---------------- wish it act as phplib ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=1690&edit=1

« previous php.pear.dev (#31017) next »