From 87bafef888e043f37f7432ed02334a2dbcc08242 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 14 Mar 2014 12:55:40 -0500
Subject: [PATCH] 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
---
 include/mysqli.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/mysqli.php b/include/mysqli.php
index 86b5a3b7f..443a1544e 100644
--- a/include/mysqli.php
+++ b/include/mysqli.php
@@ -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))
-- 
GitLab