mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
$mysqli = new mysqli($host, $user, $password);
|
||||
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, $dbname, $port, $socket);
|
||||
if (mysqli_connect_error())
|
||||
{
|
||||
throw new Exception("Can't connect to server");
|
||||
|
||||
Reference in New Issue
Block a user