duan1396 2013-11-28 08:27
浏览 169
已采纳

何时以及为何使用mysqli_fetch_row,mysqli_fetch_object,mysqli_fetch_assoc,mysqli_fetch_array [复制]

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>
  • 写回答

3条回答 默认 最新

  • duanji8615 2013-11-28 08:32
    关注

    Here are some references which should answer your question: mysqli_fetch_row, mysqli_fetch_assoc, mysqli_fetch_object, mysqli_fetch_array

    In general the PHP Documentation seems to be a good resource for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程