PHP中如何实现数据库连接池?
Possible duplicates: Connection pooling in PHP and php connection pooling mysql
I used to restore connections in $_SESSION.
but found it not good.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在php中不可能实现数据库池,因为每个请求都运行在一个全新的进程中。请求之间没有任何内容可以保留。该库可能有自己的数据库池(在 mysql api 中,称为持久连接)。对于 mysql 来说,这是没有实际意义的,因为建立新连接的成本微乎其微。
It is impossible to implement a database pool in php, because each request runs in a completely new process. There is nothing that survives between requests. The library may have its own database pool (In the mysql api, it's called persistent connections). For mysql, it's moot point though, since the cost of establishing a new connection is minuscule.
这并不是微不足道的,无论采用何种技术,数据库连接都是连接到数据库时最耗时的步骤。
It is not minuscule, database connection is the most time consuming step while connecting to DB irrespective of the technology.