Chapter 5. Interacting with a Database

In this chapter, we will cover the following topics:

  • Using PDO to connect to a database
  • Building an OOP SQL query builder
  • Handling pagination
  • Defining entities to match database tables
  • Tying entity classes to RDBMS queries
  • Embedding secondary lookups into query results
  • Implementing jQuery DataTables PHP lookups

Introduction

In this chapter, we will cover a series of database connectivity recipes that take advantage of the PHP Data Objects (PDO) extension. Common programming problems such as Structured Query Language (SQL) generation, pagination, and tying objects to database tables, will be addressed. Finally, at the end, we will present code that processes secondary lookups in the form of embedded anonymous functions, ...

Get PHP 7 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.