This question already has an answer here:
I understand in some way the differences between mysqli_fetch_row
, mysqli_fetch_object
, mysqli_fetch_assoc
and mysqli_fetch_array
.
My question is if they are so similar (if they are really almost the same as many topics say) which should we use? Why should we use the preferred one and is there some performance difference?
I have read some people say never to use mysqli_fetch_array. I am confused. I am reading now some PHP books and all the examples include it. If this is incorrect is it better for me to stop using it while exercising and use something else that you could explain and recommend?
I have also read that these are equal:
mysqli_fetch_array( $result, MYSQLI_ASSOC ) = mysqli_fetch_assoc( $result )
mysqli_fetch_array( $result, MYSQLI_NUM ) = mysqli_fetch_row( $result )
mysqli_fetch_array ( $result ) = mysqli_fetch_assoc( $result ) + mysqli_fetch_row( $result )
If they are equal as concept, are there performance differences? Which should we use? Is differences are for better performance of for better programming habits that help developers use together for easy working?
I read "Head First PHP & MySQL (A Brain-Friendly Guide)" and "VISUAL QUICKPRO GUIDE PHP 5 ADVANCED". They use different practices but authors do not explain anything about them.
I strongly believe that these differences have big reason and they have different usage and cases, but I cannot find where to use different functions and syntax.
Thank you very much in advance!
</div>