Jump to content

Proper use of MySQLi (Improved Extension)


SROSeaner

Recommended Posts

Hi,

 

I am trying to learn to use the MySQLi classes (MySQLi,MySQLi_STMT,MySQLi_Result) with great confusion.

 

I like the ability to create prepared statements, but also value the use of fetching associative arrays for the results.

 

I can prepare my statements no problem, and think it's great for sql injection prevention, but is there no way to store those results into a MySQLi_Result object as well (if it receives results in a SELECT statement, for example) so I can then fetch assoc array from the mysqli_result object?

 

Thanks for any insight,

Sean

Link to comment
https://forums.phpfreaks.com/topic/172751-proper-use-of-mysqli-improved-extension/
Share on other sites

$stmt->fetch() fetches a row from the result set and places the selected values into the variables setup with $stmt->bind_result(). How is that any different from fetching a row and accessing the elements of the array?

 

You could use array elements in $stmt->bind_result() if you desperately wanted to use array syntax to access the values from the query -

 

$stmt->bind_result($row['name'], $row['code']);

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.