Question posted by: WebCM
(Guest)
on
March 18th, 2008 05:55 PM
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. :)
Not the answer you were looking for? Post your question . . .
183,961 Experts ready to help you find a solution.
Sign up for a free account, or
Login (if you're already a member).