diff options
author | plegall <plg@piwigo.org> | 2013-04-12 21:59:42 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2013-04-12 21:59:42 +0000 |
commit | fc8b781dddd95ab2fd7ef4e1eb39408b8df40279 (patch) | |
tree | 63a6f6e8544d040a888b25657dd7f3c67cc51eae /include | |
parent | 12dd40060d6062c17eafcf1b3166cbdb24aa0ec2 (diff) |
merge r22181 from branch 2.5 to trunk
bug 2865: mysqli can now handle socket and specific port number
git-svn-id: http://piwigo.org/svn/trunk@22182 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/dblayer/functions_mysqli.inc.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/dblayer/functions_mysqli.inc.php b/include/dblayer/functions_mysqli.inc.php index 2c7f0c6af..9de75a6e5 100644 --- a/include/dblayer/functions_mysqli.inc.php +++ b/include/dblayer/functions_mysqli.inc.php @@ -36,8 +36,29 @@ define('DB_RANDOM_FUNCTION', 'RAND'); function pwg_db_connect($host, $user, $password, $database) { global $mysqli; + + // exemples of $host + // + // $host = localhost + // $host = 1.2.3.4:3405 + // $host = /path/to/socket + + $port = null; + $socket = null; + + if (strpos($host, '/') === 0) + { + $host = null; + $socket = $host; + } + elseif (strpos($host, ':') !== false) + { + list($host, $port) = explode(':', $host); + } + + $dbname = null; - $mysqli = new mysqli($host, $user, $password); + $mysqli = new mysqli($host, $user, $password, $dbname, $port, $socket); if (mysqli_connect_error()) { throw new Exception("Can't connect to server"); |