Design patterns·Objects and the database between them
you wrote no SQL, and then spent an afternoon reading the SQL it generated to find out why the page was slow.
Object-relational mapping
Also calledORM, object relational mapper
A library that maps rows to objects and generates the queries in between, usually implementing data mapper or active record plus an identity map and unit of work. It removes an enormous amount of mechanical code and gives back a layer whose performance characteristics are invisible until they are a problem. Every serious user of one ends up learning to read the generated SQL, which is the fair summary of the trade.