On Friday 19 October 2007, Lukas Kahwe Smith wrote:

> > I've actually had issues in the past with PDO and non-exception
> > error-mode
> > handling.  I had queries that were running fine but when I checked
> > the error
> > value it gave a non-OK value.  (I forget what off hand.)  As soon as I
> > switched to exceptions, it worked perfectly.  I believe this was
> > under 5.2.1.
> >
> > --
>
> Well that sounds like a bug and not like a "feature" of exceptions.
> Or are you implying that the added complexity of this switch makes it
> harder to write bug free code. I do image that its a bit annoying to
> have to write tests to cover all the error modes.
>
> regards,
> Lukas

I agree, although at the time I wasn't at the point where I could make a 
viable bug report out of it.  I was writing a database wrapper layer around 
PDO (actually porting PDO into an existing wrapper), and did find in the end 
that exception-based checking, even though it never left the wrapping 
function I had around the actual query, made the code a lot nicer to deal 
with than an if-check in each case.  The errors also made more sense, at 
least to me, than trying to get the error out of the returned error array 
with a variable number of entries in it.  

In any case, I don't find the exception usage of PDO to be a bad thing.  I 
agree it should remain possible to use PHP without having dozens of try and 
catch blocks around everything, but remember that Exceptions are popular 
exactly because they are a clean and powerful mechanism.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to