Re: PEAR DB examples?

From: Date: Fri, 08 Sep 2000 14:22:01 +0000
Subject: Re: PEAR DB examples?
References: 1 2 3 4  Groups: php.pear 
Request: Send a blank email to php-pear+get-239@lists.php.net to get a copy of this message
On Fri, 08 Sep 2000, Sterling Hughes wrote: > <?php > $dbh = DB::connect("mysql://user:pass@server/dbname"); > > if (DB::isError($dbh)) { > die(sprintf("Error [%d]: %s", > $dbh->getCode(), $dbh->getMessage())); > } > > $sth1 = $dbh->query("select article_id from articles where author_id = 1"); > > // .. same error checks apply to queries > > while (is_array($row = $sth1->fetchRow())) { > $sth2 = $dbh->query("select image_id from images where article_id = " . > $row[article_id]); > //... > } > ?> > Hmm, I see. It might get a little annoying to write error checks after each query - is there a way to automate that a bit? -Andrei It is commonly the case with technologies that you can get the best insight about how they work by watching them fail. -- Neal Stephenson

« previous php.pear (#239) next »