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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退