Binding output variables


show more Binding output variables 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 ...

Binding output variables

We've created a prepared statement that uses placeholders to insert values from an online form into an SQL query. To make it easier to handle the result set, we can bind the results of each column to named variables. So, instead of using the get_result method on line 17, we're going to use the bind_result method which takes as its arguments, the variables you want to bind the results of each column to. So, we'll get rid of this and it's our statement object and the bind_result method that we need. The number of arguments passed the bind_result must be exactly the same as the number of columns in the result set.

And they must be in the same order. So you should always declare the column name specifically in the SQL when binding the result. So, let's see. We need one for make, yearmade, mileage, price, and description. They have to be in that order. We've already got a variable called make, so we'll bind the output to maker. Then year, miles, price, and desc.

So, after binding the...

Binding output variables
Video duration: 5m 6s 3h 47m Intermediate

Viewers:

Binding output variables 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 ...