Jump to content

[SOLVED] mysql_fetch_row or mysql_fetch_assoc or mysql_fetch_array?


limitphp

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.

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.