O'Reilly logo

Building PHP Applications with Symfony™, CakePHP, and Zend® Framework by Leszek Nowak, Karol Przystalski, Bartosz Porebski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Working with Databases

To forget one's purpose is the commonest form of stupidity.

Friedrich Nietzsche

WHAT'S IN THIS CHAPTER?

  • Understanding various approaches to object-relational mapping (ORM).

  • Configuring different database engines.

  • Writing schemas of object models.

  • Using the command-line interface.

In order to produce your first application, you need to know how to communicate with your database. To communicate with it, the database must be configured properly for use with your framework. And before the configuration can be made, you should know how the frameworks join with database systems and perhaps choose your preferred object-relational mapping (ORM) solution.

To help you with that before you move to coding the sample app, this chapter takes a close look at the ORM concept, which is essential for almost every PHP framework available. The rest of the chapter covers configuring various databases for chosen ORM solutions and how to communicate with them efficiently. In the next chapter, you will write an address book example in each framework. The good thing is that with ORM support, communicating with databases is really straightforward. You no longer need to write lengthy SQL queries manually nor join tables each time you need to call another object by reference. So this little bit of overhead is certainly worth the effort.

OBJECT-RELATIONAL MAPPING

ORM is one of the core concepts of PHP frameworks. It creates an abstraction layer between relational database management ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required