June 2010
Intermediate to advanced
328 pages
7h 51m
English
Anyone who enjoys dancing knows that missteps are inevitable. The secret to remaining graceful is to know how to recover. Give yourself a chance to notice the cause of the mistake. Then you can react quickly and seamlessly, getting back into rhythm before anyone has noticed your gaffe.
Checking return status and exceptions from database API calls is the best way to ensure that you haven’t missed a step. The following example shows code that checks the status after each call that could cause an error:
| See-No-Evil/soln/check.php | |
| | <?php |
| | try { |
| | $pdo = new PDO("mysql:dbname=test;host=localhost", |
| | "dbuser", "dbpassword"); |
| ① | } catch (PDOException $e) { |
| | report_error($e->getMessage()); ... |
Read now
Unlock full access