doumaque6551 2010-01-04 04:01
浏览 76
已采纳

PHP + SQLite sqlite_exec和sqlite_query vs mysql_query

I understand that sqlite_exec is for queries that does not return result set and sqlite_query is for queries that return result set.

However can I use sqlite_query for all kinds of queries just like how mysql_query and are there any side effects to this?

  • 写回答

1条回答 默认 最新

  • dselp3944 2010-01-04 04:33
    关注

    sqlite_query

    sqlite_query() returns a buffered, seekable result handle. This is useful for reasonably small queries where you need to be able to randomly access the rows. Buffered result handles will allocate memory to hold the entire result and will not return until it has been fetched. If you only need sequential access to the data, it is recommended that you use the much higher performance sqlite_unbuffered_query() instead.

    sqlite_exec

    This function will return a boolean result; TRUE for success or FALSE for failure. If you need to run a query that returns rows, see sqlite_query().

    I don't think there will be that much difference between always using sqlite_query, although you may lose some clock cycles while sqlite_query is figuring out that there are no results. Both functions return FALSE on failure, so as long as you always check for FALSE rather than TRUE you might be able to get away with it.

    You may also want to look at sqlite_unbuffered_query if you are doing straightforward PHP database work, sequentially iterating through results from the query.

    I checked the C API for this and it doesn't give any indication of a performance penalty for using one function over the other.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?