Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以下PHP MySQLi init的最大线程限制是多少?_Php_Mysql_Mysqli - Fatal编程技术网

以下PHP MySQLi init的最大线程限制是多少?

以下PHP MySQLi init的最大线程限制是多少?,php,mysql,mysqli,Php,Mysql,Mysqli,站点范围使用以下语句调用DB连接,请理解代码包含在所有其他php文件中。看起来它将达到一个极限,因为我检查RDS端是否有多个用户的单一连接。如何确定线程的最大限制?还是最大共享池 unset($db1); $db1 = new MySQLi($db_url,$db_username,$db_password,$db_name,$db_port); $db1->query("set names utf8"); 更好的选择是在配置中更改这3个设置 mysql> he

站点范围使用以下语句调用DB连接,请理解代码包含在所有其他php文件中。看起来它将达到一个极限,因为我检查RDS端是否有多个用户的单一连接。如何确定线程的最大限制?还是最大共享池

unset($db1);
$db1 = new MySQLi($db_url,$db_username,$db_password,$db_name,$db_port);
$db1->query("set names utf8");

更好的选择是在配置中更改这3个设置

mysql> help set names;
Name: 'SET NAMES'
Description:
Syntax:
SET NAMES {'charset_name'
    [COLLATE 'collation_name'] | DEFAULT}

This statement sets the three session system variables
character_set_client, character_set_connection, and
character_set_results to the given character set. Setting
character_set_connection to charset_name also sets collation_connection
to the default collation for charset_name. See
https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html.

The optional COLLATE clause may be used to specify a collation
explicitly. If given, the collation must one of the permitted
collations for charset_name.

charset_name and collation_name may be quoted or unquoted.

The default mapping can be restored by using a value of DEFAULT. The
default depends on the server configuration.

Some character sets cannot be used as the client character set.
Attempting to use them with SET NAMES produces an error. See
https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html#charset
-connection-impermissible-client-charset.

URL: https://dev.mysql.com/doc/refman/8.0/en/set-names.html

为什么要在每个文件中包含此内容?为什么不连接一次并重新使用连接?原因是什么?线程的最大限制是什么?PHP总是在单个线程中执行。没有连接池。每次创建一个新对象时,都会建立一个新的连接,这是一个无趣的发现,因为理论上的限制取决于服务器操作系统,而有效的限制肯定取决于硬件、配置和用户限制,而且我敢打赌MySQL服务器被比您更多的应用程序共享。如果您试图解决一个特定的问题,您可能应该询问这个问题。@Ron因为PHP在执行完成后关闭连接?对于整个PHP项目,初始化一个新的$db1=new mysqli就足够了。。。。然后在整个项目中重用这个$db1。。。无需将其取消设置或重新启动,也无需将其附加到任何新的PHP文件中,在该文件中,您将包括或需要您曾经启动连接的database.PHP。。。