When and why use mysqli_fetch_row, mysqli_fetch_object, mysqli_fetch_assoc, mysqli_fetch_array

I somehow understand the differences between mysqli_fetch_row, mysqli_fetch_object, mysqli_fetch_assocand mysqli_fetch_array.

My question is, are they similar (if they are really almost the same as many say) that we should use? Why should we use the preferred option and is there a difference in performance?

I read that some people say that never use mysqli_fetch_array. I'm confused. I am currently reading several books on PHP, and all examples include it. If this is not the case, should I stop using it during exercise and use something else that you could explain and recommend?

I also read that they 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 in concept, are there differences in performance? What should we use? Are differences for better performance for better programming skills that help developers share for easy work?

I read “ Head First PHP and MySQL (The Brain-Oriented Guide ” and “ QUICKPRO GUIDE PHP 5 ADVANCED VISUAL GUIDE .” They use different practices, but the authors do not explain anything about them.

I strongly believe that these differences have a big reason, and they have different uses and cases, but I cannot find where to use different functions and syntax.

Thank you in advance!

+4
3

php.net :

mysqli_fetch_array() - mysqli_fetch_row() . , mysqli_fetch_array() , .

http://www.php.net/manual/en/mysqli-result.fetch-array.php

, , . mysqli_fetch_row mysqli_fetch_array MYSQLI_BOTH, MYSQLI_NUM ( ).

mysqli_fetch_assoc($result) mysqli_fetch_array($result, MYSQLI_ASSOC).

mysqli_fetch_object , : . mysqli_fetch_assoc , . , - stdClass .

+1

, , , : 1)

0

All Articles