php连接池mysql [英] php connection pooling mysql

查看:217
本文介绍了php连接池mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用MYSQL。是否有连接池扩展可用?或者什么是连接的正常做法?
这是在每一个使用的地方...

  mysqli_connect(localhost,xxx xxx,test); 

人们只使用正常 mysql_connect code> pconnect ..?如何更好地 pconnect 和我应该为PConnect设置什么?

解决方案

你使用过 mysql_pconnect()吗?
mysql_pconnect()非常像 mysql_connect(),有两个主要区别。



首先,当连接时,函数首先尝试找到已经用相同主机,用户名和密码打开的(持久)链接。如果发现一个,将返回一个标识符,而不是打开一个新的连接。



其次,到SQL服务器的连接将不会关闭执行脚本结束。相反,链接将保持打开以备将来使用( mysql_close()不会关闭由 mysql_pconnect()



检查这里


I am planning to use MYSQL. Is there a connection pooling extension available? Or what is the normal practice for connection? Is this the one used in every where...

mysqli_connect("localhost", "xxx", "xxx", "test");

Do people use just normal mysql_connect or pconnect..? How better is pconnect and what setting should I do for PConnect?

解决方案

have you ever used mysql_pconnect() ? mysql_pconnect() acts very much like mysql_connect() with two major differences.

First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).

This type of link is therefore called 'persistent'

Check it here

这篇关于php连接池mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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