Skip to content
Snippets Groups Projects
Commit 87bafef8 authored by Jared Hancock's avatar Jared Hancock
Browse files

mysqli: Allow for persistent database spec

Use `p:` in the database hostname specification, so `p:localhost` for
instance. This will help with SSL and remote database users.

References:
http://www.php.net/manual/en/mysqli.persistconns.php
parent 62049df7
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,9 @@ function db_connect($host, $user, $passwd, $options = array()) {
$port = ini_get("mysqli.default_port");
$socket = ini_get("mysqli.default_socket");
$persistent = stripos($host, 'p:') === 0;
if ($persistent)
$host = substr($host, 2);
if (strpos($host, ':') !== false) {
list($host, $portspec) = explode(':', $host);
// PHP may not honor the port number if connecting to 'localhost'
......@@ -54,6 +57,9 @@ function db_connect($host, $user, $passwd, $options = array()) {
}
}
if ($persistent)
$host = 'p:' . $host;
// Connect
$start = microtime(true);
if (!@$__db->real_connect($host, $user, $passwd, null, $port, $socket))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment