Mysqli - When opening 2 connections to the same host with mysql, but different databases, does mysqli open the connection once?

前端 未结 2 2036
长情又很酷
长情又很酷 2021-01-06 05:34

When I have a situation like this:

$databaseA = new mysqli($host,$user,$pass,\"databaseA\");
$databaseB = new mysqli($host,$user,$pass,\"databaseB\");
         


        
2条回答
  •  情书的邮戳
    2021-01-06 05:52

    For every mysqli-object there will be a separate connection.

    Try a

    SHOW FULL PROCESSLIST; 
    

    on your MySQL server during runtime, you'll see two different processes connected from the same host if your example is implemented.

提交回复
热议问题