Re: Re: PDO Exceptions

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

 



On 4/24/2013 9:43 AM, Lars Nielsen wrote:
On 4/22/2013 11:55 AM, Onatawahtaw wrote:
Greetings,

I am new to this list. I have a question about which functions need to
be included in a try block.

Of "new PDO", "prepare", "bindParam", "execute", "fetch", and "query",
it seems that bindParam is the only one that throws an exception. So is
this the only that needs to be put into a try block?

Thanks,

-KJW
Proverbs 3:5-6

Since nobody else has offered anything, I'll give you my impression of
how a try handles things.

If the statement(s) within the try block fail in any way (such as simply
returning a 'false' value), the try block's catch will be executed.  So
while the items you specified do not "throw an exception", I believe the
try will still handle a failure of those functions.

Of course, if I'm wrong, I'm positive we'll start seeing responses to
your question.  :)

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


Hi Jim,

I agree that failures would normally be catched as an exception. But how
do/can you determine if "false" is a failure?

/Lars

It's not a question of Me determining that. If the original function returned "false" then the try should catch it and in your 'catch' block you can display a message and show the php error. In the case where you expect a 'false' return, then just reverse your try condition, and display the appropriate message (without a php error messsage). Or even simpler, just use an If statement.

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





[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux