Learn

In our previous lesson, we looked at how to handle user input from forms. Combining PHP with a database will let us store the user input to use in our applications. In this lesson, we will learn how to use PostgreSQL to store large amounts of structured data and perform complex operations.

Let’s take a look at how we will structure our application. We will use PHP to:

  • Process information
  • Apply business logic
  • Communicate with customers, vendors, and services
  • Tell the database which operations to perform and when

We will connect a PostgreSQL database to:

  • Store data
  • Read, write, update, and delete data when PHP instructs it

There are several ways to connect PHP to a database. In this lesson, we will be using PDO (PHP Data Objects). PDO comes out of the box with all supported PHP versions. It provides a layer of abstraction that lets us write code for many popular database systems such as PostgreSQL, MySQL, MariaDB, and SQLite.

Once we connect PHP to PostgreSQL, we’ll learn how to interact with the database securely, identify and fix insecure statements, and catch errors during our program’s execution.

Let’s get started with learning how to combine PHP with PostgreSQL to create powerful and dynamic user experiences!

Instructions

Take a look at the code editor. You’ll see the code we will go over throughout this lesson. Click “Next” when you’re ready to move on!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?