PHP PDO Caching

后端 未结 4 632
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:11

    Two subsequent calls to PDO::prepare() (even with the same SQL query) should return two different PDOStatement (or handles) to avoid collisions, especially between previous and current bindings you may apply to it. The cost of creating a PDOStatement with prepare() is low anyway. What you may want cached are the results returned from the same SQL query, either raw or built by prepare() and this is a feature of your DBMS (MySQL for instance), not PHP.

提交回复
热议问题