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 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?