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 a concept, are there performance differences? Which should we use? Are the differences because of performance reasons or for the developer's convenience?
I strongly believe that these differences have a big reason and they have different usage and cases, but I cannot find where to use different functions and syntax.