常用连接函数mysql_connect()
mysql_connect(servername,username,password);
长连接函数mysql_pconnect()
mysql_pconnect(servername,username,password);
代码如下 | 复制代码 |
<?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } // some code ?> |
说的是mysql_pconnect,怎么能绕开MySQL的设置。影响mysql_pconnect最重要的两个参数就是wait_timeout和interactive_timeout
代码如下 | 复制代码 |
<?php $conn = mysql_pconnect("localhost","root","123456") or die("Can not connect to MySQL"); echo "MySQL线程号:". MySQL_thread_id($conn). "<br />"; echo "Apache进程号". getmypid(); ?> |
时间: 2024-09-24 22:36:20