--- Chris <[EMAIL PROTECTED]> wrote:
> Prabath Kumarasinghe wrote:
> > 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();
> >
> > }
> > -------------------------------------------
>
> Since mysql_query doesn't throw an exception, you
> cannot catch it.
>
> mysql_query returns false if an error occurs,
> otherwise it returns a
> result resource.
>
> http://www.php.net/mysql_query
But it's give a many information using $e->getTrace()
is this correct. If there are several mysql_query then
I can put it as bunch within try block and catch
exception easily.
In second approach for every query I have to write
throw new MySQLException("My Message"). It's very time
consuming isn't it?
Cheers
Prabath
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php