Welcome Guest, Not a member yet? Register   Sign In
How to pass the socket into the connection string?
#1

[eluser]@robertotra[/eluser]
Hello,
in the connection options to connect to the database there is the port:

Code:
$db['default']['port'] = 5432;

but how can I pass also the socket? It is the last option in the mysqli connection:

Code:
mysqli::__construct() ([ string $host = ini_get("mysqli.default_host") [, string $username = ini_get("mysqli.default_user") [, string $passwd = ini_get("mysqli.default_pw") [, string $dbname = "" [, int $port = ini_get("mysqli.default_port") [, string $socket = ini_get("mysqli.default_socket") ]]]]]] )

will the following work?

Code:
$db['default']['socket'] = '/my/path/to/socket';

or there is another way? Or should I add my custom code to the connector in order to send also the socket?

Thank you in advance and regards
Roberto
#2

[eluser]InsiteFX[/eluser]
Connecting with different hosts ports and sockets
#3

[eluser]aquary[/eluser]
I'm assuming you are using CI's mysqli driver. I've checked the driver file and found that they didn't include the socket parameter in the mysqli_connect(). I guess you will have to modify the driver by yourself for the time being.

Code:
function db_connect()
{
   if ($this->port != '')
   {
      if(!empty($this->socket))
         return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port, $this->socket);
      else
         return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
}
else
{
   if(!empty($this->socket))
      return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, NULL, $this->socket);
   else
      return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
}

}
Then setting a config for socket like you said should already do the job...
#4

[eluser]@robertotra[/eluser]
[quote author="aquary" date="1332833807"]I'm assuming you are using CI's mysqli driver. I've checked the driver file and found that they didn't include the socket parameter in the mysqli_connect(). I guess you will have to modify the driver by yourself for the time being.

[...]

Then setting a config for socket like you said should already do the job...
[/quote]

It is right what I needed.
I imagined I have to add the socket option in such a way.
Maybe EllisLab will consider to add it into a future release of CodeIgniter for complete alignment to mysqli constructor.

Thank you very much and best regards
Roberto




Theme © iAndrew 2016 - Forum software by © MyBB