Passing an array of values to the execute() method


show more Passing an array of values to the execute() method 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 ...

Passing an array of values to the execute() method

In addition to binding values to placeholders with the bindParam and bindValue methods, PDO allows you to pass the values directly to the execute method as an array. When you do this, all values are treated as strings. You can either define the array first or create it directly between the parentheses of the execute method. We'll look at both ways. This is pdo_named_excute.php, which you can find in the chapter three 03_04 folder of the exercise files.

It's exactly the same file as the one we created earlier using named parameters. Because the parameters have names, you need to create an associative array using the name as the key for each value. Because they're individually named, they can be in any order. So, let's create a new array. We'll create it after preparing the statement. We'll call the array values and just because we can, let's put them in a different order.

So, we'll start off with colon price. And the double arrow operator for the value. That comes directly ...

Passing an array of values to the execute() method
Video duration: 5m 20s 3h 47m Intermediate

Viewers:

Passing an array of values to the execute() method 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 ...