Which one is better to fetch data from mysql database using PHP and why?
mysql_fetch_row()
mysql_fetch_assoc()
mysql_fetch_array()
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
mysql_fetch_row()
It returns array with numeric index/key. Usually it is the faster compare with two other methods.
mysql_fetch_assoc()
It returns array with column name as key. It is slightly slower than mysql_fetch_row().
mysql_fetch_array()
It returns returns essentially two arrays. One with an associative based key index and one with a numeric index. mysql_fetch_array() without specifying which method you want (either MYSQL_NUM or MYSQL_ASSOC) always returns a double array. And it is considerably more inefficient as compared to mysql_fetch_row() or mysql_fetch_assoc(). You can set the result type as second parameter.
I think, actually those method has no significant difference.