Working with PDO

In this section, we will be creating the PDO wrapper and using a database as a data source from our model.

From this section, we will gain the ability to use a database within our framework project.

Six methods will be covered here.

We have a get method — this is for creating a connection to the database and making sure it is a singleton instance, meaning it can only ever have one instance:

  • We have a raw method for running raw, unsecured queries
  • A select method for running secure queries to select records from the database
  • An insert method to create new records
  • An update method to update records
  • A delete method to delete records
  • A truncate method to empty a table

What this does is allow your CRUD to work. Without this class, CRUD functionality ...

Get Beginning PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.