From the course: PHP Tips, Tricks, and Techniques

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Debugging PDO prepared statements

Debugging PDO prepared statements

- [Instructor] Hi; I'm David Powers, and welcome to this week's edition of PHP tips, tricks, and techniques designed to help you become a smarter, more productive PHP developer. This week's tip is a quick and easy one, but it's one that can help preserve your sanity. I want to show you how to debug a PDO-prepared statement. For this, you'll need to be using PHP 7.2 or later. In this file, I'm using a PDO-prepared statement with a named parameter like this to query a database. The exercise files for this video contain a copy of this script, but not of the database or the database connection. The technique I'm going to demonstrate is very simple, so you can work with a database of your own. This works not only with named parameters; you can also use question marks as placeholders in the prepared statement. For demonstration purposes, I'm hard-coding the value of year, here on line three. Normally, this would come from a dynamic source, such as a query string. The script prepares the…

Contents