Jump to content

mysqli prepared statements


skaterdav85
 Share

Recommended Posts

Normally, you use something like mysqli::fetch_array() that returns an array of the results. You then access each array member to get the corresponding value, and once you make another call to fetch_array(), you get a new array.With binded results, instead of returning an array, you can create a variable that stores the corresponding column value, and then use the variable name directly, instead of processing an array. Another call to fetch() is going to change that variable's value.

Link to comment
Share on other sites

I don't think there's an advantage of any kind... it's just an alternative way of dealing with the result.In a similar fashion, there's no real advantage of binded parameters - they're just another way to prevent SQL injections, which you'll prevent anyway if you use mysqli_real_escape_string() and explicitly type cast everything that's a number. Now... for binded parameters, you can argue that it's easier to work with them, because they automatically do the string and/or cast, but the point is that the resulting query is the same.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...