Mysql-php 如何使用php v 5.2 实现连接池且不允许持久连接 [英] Mysql-php how to implement connection pool with php v 5.2 and no persistent connection allowed

查看:37
本文介绍了Mysql-php 如何使用php v 5.2 实现连接池且不允许持久连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 php v5.2.17 中实现连接池,所以这个版本不存在单例.显然,我的虚拟主机不允许持久连接,如 php phpinfo() 所示:

Is there any way to implement connection pooling in with php v5.2.17 , so singleton is not present for this version. Also apparently persistent connections not allowed by my webhost as php phpinfo() shows:

指令.......................本地价值…………主价值mysql.allow_persistent .....................关闭..............................关闭

Directive..................................Local Value........................Master Value mysql.allow_persistent........................Off....................................Off

如果没有连接池是可能的,那么有什么解决方法吗?使用其他语言等.减少mysql连接数对我来说是必须的.

If no connection pool is possible then can there be any workaround? use some other language etc. It is a must for me to reduce number of mysql connections.

此外,用户对数据库的查询是完全相同的查询,即它不依赖于用户或会话.它是一个硬编码的歌曲查询.以防万一这些信息可能会有所帮助.谢谢.

Also the query to the database by the users is exactly the same query i.e. it is not dependent upon the user or the session. Its a hardcoded songle query. Just incase this info might help. thanks.

推荐答案

我同意 @SDC 给出的评论,只是想让这个正式".

I agree with the comments @SDC gives, just wanted to mak this "formal".

考虑到所有这些,恐怕您不走运了.您无法在该版本的 PHP 中创建持久连接.您唯一的选择是 mysql_pconnect,它显然已被主机禁用.

Given all that, I'm afraid you're probably out of luck. You have no way in that version of PHP to create persistent connections. Your only option was mysql_pconnect, which obviously have been disabled by the host.

您只能选择@SDC 建议的三个选项:

You're down to the three options @SDC suggests:

  • 让他们允许/升级 PHP.
  • 切换到更宽容的主机.
  • 自托管

这篇关于Mysql-php 如何使用php v 5.2 实现连接池且不允许持久连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆