Allow local socket connection to MySQL DBs, from bug #878395

This commit is contained in:
shrykedude 2004-01-17 19:42:02 +00:00
parent 9ea48598cf
commit 9197af0108

View File

@ -41,6 +41,12 @@
{ {
$Port = isset($this->Port) ? $this->Port : '3306'; $Port = isset($this->Port) ? $this->Port : '3306';
} }
// Check if using local socket instead of TCP/IP
if (substr($Port,0,1) == '/')
{
$Host = '';
}
$Host = $Host.':'.$Port;
if ($User == '') if ($User == '')
{ {
$User = $this->User; $User = $this->User;
@ -49,7 +55,6 @@
{ {
$Password = $this->Password; $Password = $this->Password;
} }
$Host = $Host.':'.$Port;
/* establish connection, select database */ /* establish connection, select database */
if (! $this->Link_ID) if (! $this->Link_ID)
@ -67,7 +72,6 @@
$this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host, $User, \$Password) failed."); $this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host, $User, \$Password) failed.");
return 0; return 0;
} }
if (!@mysql_select_db($Database,$this->Link_ID)) if (!@mysql_select_db($Database,$this->Link_ID))
{ {
$this->halt("cannot use database ".$this->Database); $this->halt("cannot use database ".$this->Database);