Jump to content

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']);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.