PHP Portal » PHP Handbuch » Persistent Connections

Werbung

Persistent Connections


Using Persistent Connections

The MySQL database extensions do not support persistent connections when used with the MySQL Client Library. However, they do when using MySQL Native Driver. When creating a connection the hostname is prepended with "p:". This is demonstrated by the following code snippet, which creates a new connection using mysqli:

$host="p:localhost";
$port=3306;
$socket="/tmp/mysql.sock";
$user="root";
$password="password";
$dbname="test";

$conn = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());