Re: Re: PDO Exceptions
| From: | Jim Giner | Date: | Wed, 24 Apr 2013 14:00:17 +0000 |
| Subject: | Re: Re: PDO Exceptions | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48724@lists.php.net to get a copy of this message | ||
On 4/24/2013 9:43 AM, Lars Nielsen wrote:
On 4/22/2013 11:55 AM, Onatawahtaw wrote: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.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-6Since 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