Hi All

Recently I'm came across following code snippet
regarding exceptions there I'm executing invalid query
and catch the exception as follows.

First Approach
-------------------------------------------
try{
$result = mysql_query('SELECT * from unknowntable');


}catch(exception $e){
  echo $e->getTrace();

}
-------------------------------------------


Second Approach
-------------------------------------------
try{

$result = mysql_query('SELECT * from unknowntable');
if (!$result) {
    throw new MySQLException('Query failed to
execute')
}

}cathc(MySQLException $e){
     echo $e->getMessage();
}cathc(Exception $e){
     echo $e->getMessage();
}
-------------------------------------------

Which one is the best approach and efficient and what
the recommended approach.

Cheers

Prabath


      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to