Re: Pear DB Tutorial

From: Date: Mon, 16 Apr 2001 16:06:09 +0000
Subject: Re: Pear DB Tutorial
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-237@lists.php.net to get a copy of this message
Andrei Zmievski wrote: > > Has anyone written a simple wrapper around PEAR DB stuff? I don't want > to do DB::isError() after every method call, pretty much. Having it > simplified would be nice. > I can think a simple "error filter" system so (code not tested): <?php // what kind of error message to output define (DEBUG_ENV, true); function handle_error (&$res) { if (DB::isError($res)) { // here you can set the default actions to take // or set pear error handling if (DEBUG_ENV) { die($res->getDebugInfo()); } die ($res->getMessage()); } return $res; } $db = handle_error(DB::connect($dsn)); $res = handle_error($db->query($sql)); $numrows = handle_error($res->numRows()); ?> Tomas V.V.Cox

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