Re: Installing PEAR

From: Date: Thu, 25 Jan 2001 18:23:22 +0000
Subject: Re: Installing PEAR
References: 1  Groups: php.pear 
Request: Send a blank email to php-pear+get-1169@lists.php.net to get a copy of this message
On Thu, 25 Jan 2001, Stig S. Bakken wrote: > To me it sounds like DB::connect returns an error. Errors are by > default also objects, and they don't have a query() method. You should > add a check for it like this: > > <?php > error_reporting(1023); > include_once("settings.php"); > require_once( 'DB.php' ); > $db = DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" ); > $sql = 'SELECT * FROM demo'; > $demoResult = $db->query($sql); > if (DB::isError($demoResult)) { > print $demoResult->getMessage(); > exit; > } > while ($demoRow = $demoResult->fetchRow()) { > echo $demoRow[2] . '<br>'; > } > $db->disconnect(); > ?> > Indeed, I eventually found the problem by messing with 001.php that comes on the mysql sub-directory under DB/. Coming from a PHPLIB DB_* experience, it took me some time to actually understand the returned value from all the sub-levels of classes / method and stuff inside DB.php. Since we are already talking about this, it would be nice to have an example script like this on the distribution of PEAR somewhere, like /usr/local/lib/php/PEAR_examples or whatever. I got this code from an article at PHPBuilder and there was no error checking like this. Anyway, just my .2c Joao -- João Prado Maia <jpm@phpbrasil.com> http://phpbrasil.com - php com um jeitinho brasileiro

« previous php.pear (#1169) next »