Great job on completing this lesson. Let’s take a moment to review some of the material covered in this lesson:

  • Databases store data for PHP applications.
  • PDO lets us write code that will work with many common database systems.
  • We write queries by inserting SQL into the query() method.
  • SQL queries with user-defined parameters (variables) are vulnerable to SQL injection.
  • We use prepared statements to prevent SQL injection.
  • Prepared statements use the prepare() and execute() methods and send SQL commands and data separately.
  • For exception handling, we wrap code in a try/catch block.
  • We use exception handling to catch and handle exceptions when our program throws them.
  • We can use methods on the exception object to troubleshoot exceptions.

You’re now well on your way to creating database-driven PHP applications!


Looking for some more practice? Consider adding tables to the database and writing more complex SQL statements.

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?