Jump to content

[SOLVED] mysql_fetch_row or mysql_fetch_assoc or mysql_fetch_array?


Recommended Posts

If you have a query where you know the result will only be 1 row, do you typically use mysql_fetch_row for that, or stick with mysql_fetch_assoc or mysql_fetch_array or something else?

 

Is there a speed advantage to using mysql_fetch_row?

 

Thanks

If you have a query where you know the result will only be 1 row, do you typically use mysql_fetch_row for that, or stick with mysql_fetch_assoc or mysql_fetch_array or something else?

 

Is there a speed advantage to using mysql_fetch_row?

 

Thanks

 

In order to for you to know which to use you'll need to know what each of the above returns.

 

mysql_fetch_assoc - returns an associative array of your field names eg $row['field_name_here']

 

mysql_fetch_row - returns a numeric array eg $row[0] returns the first column, $row[1] returns the second column etc.

 

However mysql_fetch_array retuns both an associative and numeric array.

 

I personally use mysql_fetch_assoc.

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.