Part of being able to write decent code is having the ability to know exactly what’s going on with the various services you’re interacting with, the webserver, the database and PHP itself for starters. If you’re using a database abstraction layer, sometimes you’d be surprised by the SQL that results from your API calls. This is even more the case if you’re using a data access layer like PEAR’s DB_DataObject, for example, which sits on top of PEAR::DB.
I recently had an issue where the integrity of a transaction was failing, but the point of failure was difficult to pinpoint. The first problem to tackle was the use of sequences, which is a great way to avoid getting locked in to how a particular database vendor handles incrementing record IDs, I’m thinking here of the MySQL-only concept of auto-increment.