Re: Re: Call to undefined method DB_Error::fetchRow() ? SOLVED
| From: | Jacques | Date: | Fri, 17 Dec 2004 05:35:34 +0000 |
| Subject: | Re: Re: Call to undefined method DB_Error::fetchRow() ? SOLVED | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16279@lists.php.net to get a copy of this message | ||
Matthew Weier O'Phinney escreveu:
* Jacques Nunes <iacques@yahoo.com.br>:With debug i can view a query error. Thanks for help-me!!! Jacques -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.5.4 - Release Date: 15/12/2004--0-2110549123-1103216224=:36169 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit This code runing ok with MySql 4.018 / PHP4 $dsnMySql = "mysql://***:***@localhost/framework"; $dbMySql = DB::connect($dsnMySql); $resultMysql = $dbMySql->query("SELECT * FROM ..."); $rowMysql = $resultMysql->fetchRow(DB_FETCHMODE_OBJECT); But with MySql 4.17/PHP5 $dsnMySql = "mysqli://***:***@localhost/framework"; $dbMySql = DB::connect($dsnMySql); $resultMysql = $dbMySql->query("SELECT * FROM ..."); $rowMysql = $resultMysql->fetchRow(DB_FETCHMODE_OBJECT); Fatal error: Call to undefined method DB_Error::fetchRow() in C:\desenvolvimento\framework\bin\modules\ReplicaSrh\ReplicaSrhReplicate.php on line 105 It´s a bug?No. You need to do some error checking in your code: $resultMysql = $dbMySql->query("SELECT * FROM ..."); if (DB::isError($resultMysql)) {exit("Error encountered: " . $resultMysql->getMessage());} $rowMysql = $resultMysql->fetchRow(DB_FETCHMODE_OBJECT); Basically, an error is occurring in the query, and you're getting a DB_Error object returned instead of a DB_Result; check for that before trying to fetch data from the result. Another way to do this is to trap PEAR/DB errors using PEAR's setErrorHandling() method -- that way you can trap them without needing to explicitly check for them in your code each time you run a query. I´ms solved my problem.