Pages: 1
A user on my system has reported that the upgrade to piwigo 2.5 gives a database error. Investigations reveal that this is because the file includes/dblayer/functions_mysqli.inc.php assumes a network based connection to the mysql database. This is the line:
$mysqli = new mysqli($host, $user, $password);
Support for sockets can easily be added by changing this to:
if (substr($host, 0, 1)==':')
{
$mysqli = new mysqli('localhost', $user, $password, null, null, substr($host, 1));
}
else
{
$mysqli = new mysqli($host, $user, $password);
}
It uses the (fairly standard) approach of specifying ":/path/to/socket" as a hostname.
Regards,
Greg
Offline
I even didn't know this exists
We will add it for Piwigo 2.5.1
[Bugtracker] ticket 2865
Offline
I can find any documentation on how to use mysql sockets
is the host always "localhost" ?
also I realized that mysqli has a specific field for the port, but doesn't the syntax "myhost:3307" for the host field works too ?
if teh answer is no to both questions, we need to add some string parser to transform $host into host, port and socket
Offline
Looking at some other projects, there seem to be two ways to identify sockets.
The first is to prefix the path with a colon.
The second is to look for the leading "/" in the path.
If you cannot decide, I would vote for the second option.
<<I can find any documentation on how to use mysql sockets
is the host always "localhost" ?>>
The host field is ignored. NULL works, and is probably the cleanest solution.
I'm currently using this in piwigo
if (substr($host, 0, 1)=='/')
{
$mysqli = new mysqli(null, $user, $password, null, null, $host);
}
else
{
$mysqli = new mysqli($host, $user, $password);
}
FYI, with the PHP/PDO interface, there is actually a different connection string completely. Use code like this
$pdo=new PDO(
(substr($DBHOST, 0, 1)=='/' ?
"mysql:unix_socket={$DBHOST};dbname={$DBNAME}" :
"mysql:host={$DBHOST};dbname={$DBNAME};port={$DBPORT}"
),
...
);
If you don't have a suitable machine for testing (i.e. a unix server with MySQL listening on a socket), I can test this for you.
Last edited by fisharebest (2013-03-19 18:43:02)
Offline
Hi fisharebest,
fisharebest wrote:
If you don't have a suitable machine for testing (i.e. a unix server with MySQL listening on a socket), I can test this for you.
Can you please test this version of include/dblayer/functions_mysqli.inc.php ?
http://piwigo.org/dev/export/22181/bran … li.inc.php
(related to [Subversion] r22181)
Offline
Pages: 1