[PDO] Displaying errors - silent mode, warnings or exceptions?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

PDO offers 3 modes of displaying errors:
- silent mode - no errors
- warnings - Warning:
- exceptions - Exception:

Which of them is the fastest and the most adequate for applications
like CMS and forums? I've been using exceptions now. However, let's
come to the point where EDITOR posts a filled FORM (message,
article...). He cannot lose his work!

In case of EXCEPTIONS:

try{} catch(PDOException $e){/*send form back*/}

Covering only PDO::commit() into TRY{} is not enough because script
execution is stopped if an error occurs. It concerns even
PDO::prepare() (tested with SQLite database). Some typos or incorrect
SQL functions, bidding... can cause errors in this case.

If we put only commit() into try{}, maybe the probability of losing
form's data  is low but we should consider: compability issues between
MySQL / SQLite / their versions, other configurations or even bugs in
our scripts.

Is replacing exceptions with **silent mode** or **warnings** (for
debugging) good decision or can it make a potential security bug?

if( $db->commit() ) { } else { /*send form back*/ }

PS. If exceptions are better for databases, argue it and tell us more,
why. :)

Site Timeline