Exception vs exception

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux