limitphp Posted December 12, 2008 Share Posted December 12, 2008 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 Link to comment https://forums.phpfreaks.com/topic/136688-solved-mysql_fetch_row-or-mysql_fetch_assoc-or-mysql_fetch_array/ Share on other sites More sharing options...
flyhoney Posted December 12, 2008 Share Posted December 12, 2008 I imagine its negligible if there is a speed advantage. Use whatever makes the code most readable. Link to comment https://forums.phpfreaks.com/topic/136688-solved-mysql_fetch_row-or-mysql_fetch_assoc-or-mysql_fetch_array/#findComment-713776 Share on other sites More sharing options...
wildteen88 Posted December 12, 2008 Share Posted December 12, 2008 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. Link to comment https://forums.phpfreaks.com/topic/136688-solved-mysql_fetch_row-or-mysql_fetch_assoc-or-mysql_fetch_array/#findComment-713931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.