PHP PDO Caching

后端 未结 4 631
Happy的楠姐
Happy的楠姐 2021-01-18 03:48

I\'ve been looking for an answer to this but haven\'t found it anywhere. Are calls to PDO::prepare() cached, or should I cache the result myself, i.e. if I do the following

4条回答
  •  遇见更好的自我
    2021-01-18 04:19

    It depends on your database driver. With MySQL, PDO will create a native prepared statement by default. You can disable it, if you want to use an actual query cache.

    If you absolutely must execute the same query repeatedly, then yes, you'll want to keep that handle around. If you're using emulated prepared statements, then it makes no difference at all.

提交回复
热议问题