Understanding PHP Data Objects (PDO)
4.2 (25 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
380 students enrolled

Understanding PHP Data Objects (PDO)

Learn to use the PDO library to access databases using PHP
4.2 (25 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
380 students enrolled
Last updated 2/2017
English [Auto-generated]
Current price: $34.99 Original price: $49.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 1.5 hours on-demand video
  • 2 articles
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Work with MySQL and other database software from PHP including connecting, inserting, updating records, displaying database records in lists within HTML and database security.
Course content
Expand all 18 lectures 01:43:03
+ Understanding PHP Data Objects (PDO)
4 lectures 22:25

Explains how to list the available database drivers installed on the system that can be used with PDO

Preview 03:05

Setting up an example database, explaining each column and inserting some example records that we can use throughout the series.

Preview 04:12

Using PHP to connect to the database and checking what we can do if a connection fails


Setting error levels for PDO, so we can check for errors in different ways.

Error Levels
+ Fetching Results
6 lectures 39:28

Sending a basic query to the database server.

Basic Queries

Fetching a list of results from our database table, and examining the data we receive

Fetching Results

Looping over results so we can display them in a list or modify them. We use some HTML to display results to a user on a page.


Showing an easier way to fetch all results using one method so we don't need to loop over each row

Fetch All

Fetching results as an object, so we can work with data in true object oriented style and make our application clean and the data easier to work with.

Fetch As Object

Getting the count of rows in the results so we can either display the amount of results we have, or use this number for later calculations.

Row Count
+ Hands On Project: User Class Dates
1 lecture 09:51

A small side project, creating a PHP class to represent a user in the system, which allows us to implement methods (functions) for each user we get back. This keeps our application DRY (do not repeat yourself) and much easier to work with, saving time in the future.

Project: User Class Dates
+ Security
2 lectures 13:45

A look at security, and escaping data before we use it in our database queries, to help prevent against SQL injection.


Prepared statements that help query with large amounts of user data and more importantly automatically protect against SQL injection without having to manually escape each peice of data.

Prepared Statements
+ Inserting
3 lectures 11:35

Inserting new records into the database.


Getting the last inserted ID of the record so we can perform future queries using the last record as a reference.

Last Inserted ID
Request a Course
+ Bonus Material
1 lecture 00:13
Bonus Lecture: Course Discounts
  • Will require a webserver (Apache or Nginx) with PHP 5.1 or greater, and MySQL installed. Students will also require database management software such as Sequel Pro (Mac), HeidiSQL (Windows) or MySQL workbench (Linux).

The course teaches PHP Data Objects (PDO), the preferred way to connect to databases within PHP. It covers connecting to the database, and using all the features required to build fast, scalable applications that use a database connection. It covers essential concepts like security, and best practices with using the data retrieved from the database.

While a basic knowledge of PHP is recommended for this course, both beginners and experienced web developers will gain a complete understanding of how PHP Data Objects work.

A basic knowledge of PHP is recommended for this course. You will need to be able to open and write to a basic PHP file and be able to have a server and database installed. This course will use MySQL server.

Exactly What Is PDO?

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.

Who this course is for:
  • Anyone with basic knowledge of PHP, database experience not required but is helpful, as this is demonstrated.