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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据