dongtie0929 2015-12-13 20:37
浏览 45
已采纳

将连接变量传递给函数 - PDO PHP

When executing functions in the same script:

Should I open a new connection in each function, or should I pass the last connection variable as a parameter?

Is passing the connection variable as a parameter a good practice?

  • 写回答

1条回答 默认 最新

  • donglianer5064 2015-12-13 21:16
    关注

    If you have several functions using the same PDO connection instance, you should pass this variable to your functions instead of instanciating an new object for each function this way you will have less overhead.

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

报告相同问题?