On Thu, 2008-02-21 at 21:01 -0800, Prabath Kumarasinghe wrote:
> In second approach for every query I have to write
> throw new MySQLException("My Message"). It's very time
> consuming isn't it?
In order to *be* lazy, you have to *think* lazy...
Don't go and define every single query with an exception, thats just not
the lazy way, rather define a few functions that do generic stuff (or
even a single function that runs a query) and then send all of your
queries through that:
public function queryWithException($filter)
{
$results = $dblayer->query($filter);
if($results === FALSE)
{
throw new MyException("Query failed!");
}
else {
return $results;
}
}
then in your code:
try {
$this->queryWithException("SELECT * FROM users WHERE clue > 0");
}
catch (MyException $e)
{
// clean up
}
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php