Jump to content

mysqli prepared statements


skaterdav85

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

So what is the advantage of bound results? Just the fact that you can use the values from a particular column in the db later on in the script rather than outputting them right after they have been fetched?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...