Chapter 19. Database connection, abstraction, and configuration

 

This chapter covers:

  • 19.1 Database abstraction 433
  • 19.2 Decorating and adapting database resource objects 438
  • 19.3 Making the database connection available 442
  • 19.4 Summary 448

Databases are a major component of any programmer’s diet. PHP programmers eat databases for breakfast, not to mention lunch, dinner, and late-night snacks. With MySQL in particular (and more recently SimpleSQL), databases have been fast food for many years: easy to install, deploy, and use.

But as any health fanatic will tell you, frivolous eating is dangerous. The first risk we run when consuming food is indigestion. The digestive process is supposed to work painlessly, but sometimes it doesn’t. In programming, we call these bugs. We’re inured to them, though. We’re not like the people who scream and tear their hair out whenever the printer stops working. Those people probably are constitutionally incapable of working in computer programming.

The next possible obstacle in food consumption is constipation. Something similar happens in software development when the development process slows down due to the need for increasingly complex queries. If the application is complex and needs to store complex data, that’s partly unavoidable. But the more we understand about the relationship between data and code, the better equipped we will be to make it work and keep it working.

19.1. Database abstraction

19.2. Decorating and adapting database resource objects

19.3. Making the database connection available

19.4. Summary