Using named parameters


show more Using named parameters provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP show less
please wait ...

Using named parameters

PDO has the option of using either named or anonymous parameters in prepared statements. We'll begin by looking at named parameters and how to bind values to them. This is pdo_named.php, which you can find in the Chapter 3 03_02 folder of the exercise files. Let's take a quick look at this page in a browser. It contains a search form with a text input field two select menus and a submit button.

At the moment, the PHP script ignores the values in the form fields. So if I change these select menus, say to 2005. And to 10,000. Leave the make field blank. And click Search. Instead of getting the results that I want, the page displays a complete set of results from the cars and makes tables in the OOPHP database. We need to embed the values submitted by the form into the SQL. And we'll do that using a prepared statement.

So let's go back to the editing program. And the search criteria need to be added to the SQL as a WHERE clause. So we'll put the WHERE clause on a new line after line seve...

Using named parameters
Video duration: 9m 51s 3h 47m Intermediate

Viewers:

Using named parameters provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP

Subject:
Developer
Software:
PHP
Author:
please wait ...