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?

图片转代码服务由CSDN问答提供 功能建议

在同一个脚本中执行函数时:

我应该打开一个新的 每个函数中的连接,还是应该将最后一个连接变量作为参数传递?

将连接变量作为参数传递是一种好习惯吗?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    点赞 打赏 评论

相关推荐 更多相似问题