Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 18th, 2008, 05:55 PM
WebCM
Guest
 
Posts: n/a
Default [PDO] Displaying errors - silent mode, warnings or exceptions?

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. :)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.