使用php使用mod_dbd连接mysql

发布于 2024-09-24 04:19:13 字数 178 浏览 1 评论 0原文

我想使用 mod_dbd 为我的 php 应用程序实现连接池。我能够为 apache 定义 mod_dbd 模块,并且可以看到它正在打开的连接,但我无法使用我的 php 代码“挂钩”这些连接。我正在尝试带参数和不带参数的 mysql_connect 以及 mysql_pconnect。

欢迎任何建议,

阿里尔

I would like to use mod_dbd to implement connection pooling for my php application. I am able to define the mod_dbd module for apache and I can see the connections that it is opening, but I am not able to "hook on" those connections with my php code. I was trying mysql_connect with parameters and without as well as mysql_pconnect.

Welcome any advice,

Ariel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卷耳 2024-10-01 04:19:13

为了受益于 mod_dbd 的连接池功能,您需要运行线程 MPM,以便多个线程可以共享池中的连接。不幸的是,我确实相信 PHP 不是线程安全的,并且不支持线程 MPM。

如果您将 mod_dbd 与 pre-fork MPM(它不是线程化的,建议用于 PHP)一起使用,mod_dbd 将创建单个持久数据库连接,与不使用 mod_dbd 的 PHP 中的数据库连接相比,这不会给您带来任何巨大的优势。

In order to benefit from the connection pooling feature of mod_dbd you would need to run a threaded MPM so that several threads can share the connections in the pool. Unfortunately I do believe PHP is not thread-safe, and will not support threaded MPMs.

If you use mod_dbd with the pre-fork MPM (which is not threaded and recommended for PHP) mod_dbd will create a single persistent database connection, which does not give you any huge advantage compared to a database connection in PHP not using mod_dbd.

空城缀染半城烟沙 2024-10-01 04:19:13

http://bugs.php.net/bug.php?id= 51865&edit=1

应该将其实现为
实现了像 mysqlnd 这样的扩展,
允许其他人继承
抽象代码。很有可能
PECL 中可能会出现这样的情况,
但对于核心 PHP 来说它不是很
可能我们中的任何人都会
努力吧。

此外,您还必须记住,它
需要进行大量更改才能允许
Apache 下的连接池,
同时允许
使用另一个非 Apache 的扩展
基于网络服务器,如 IIS 工作
和。否则扩展就会失败
太有限了。

只是引用我在谷歌上搜索到的内容

http://bugs.php.net/bug.php?id=51865&edit=1

One should implement this as an
extension like mysqlnd is implemented,
allowing others to inherit from the
abstraction code. Its quite possible
such a thing might come up in PECL,
but for the Core PHP its not very
likely that any of us are going to
work on it.

Also you have to keep in mind that it
requires alot of changes to allow
connection pooling while under Apache,
and at the same time allowing an
extension to use another, non Apache
based webserver, like IIS to work
with. Else the extension would get way
too limited.

Just quoting from what I googled

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文