aboutsummaryrefslogtreecommitdiffstats
path: root/include/dba
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-23 17:05:08 -0700
committerzotlabs <mike@macgirvin.com>2016-10-23 17:05:08 -0700
commitd30892ea601e9131c6dc3b25aeee1f258f72a104 (patch)
tree839c836dabc366e219cb201db6ce683a02b3f55b /include/dba
parent04ac04e0ada6b8dbe3f512379abd2859eb758173 (diff)
downloadvolse-hubzilla-d30892ea601e9131c6dc3b25aeee1f258f72a104.tar.gz
volse-hubzilla-d30892ea601e9131c6dc3b25aeee1f258f72a104.tar.bz2
volse-hubzilla-d30892ea601e9131c6dc3b25aeee1f258f72a104.zip
pdo hacks
Diffstat (limited to 'include/dba')
-rwxr-xr-xinclude/dba/dba_driver.php9
-rwxr-xr-xinclude/dba/dba_pdo.php13
2 files changed, 18 insertions, 4 deletions
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index b4cda6d8e..afe209feb 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -53,7 +53,14 @@ class DBA {
}
else {
- if(!($port))
+
+ // attempt to use the pdo driver compiled-in mysqli socket
+ // if using 'localhost' with no port configured.
+ // If this is wrong you'll need to set the socket path specifically
+ // using a server name of 'mysql:unix_socket=/socket/path', setting /socket/path
+ // as needed for your platform
+
+ if((!($port)) && ($server !== 'localhost'))
$port = 3306;
}
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php
index c2f9c5b09..8ba0adb99 100755
--- a/include/dba/dba_pdo.php
+++ b/include/dba/dba_pdo.php
@@ -107,7 +107,7 @@ class dba_pdo extends dba_driver {
return 'string_agg(' . $fld . ',\'' . $sep . '\')';
}
else {
- return 'GROUP_CONCAT(DISTINCT '.$fld.' SEPARATOR \''.$sep.'\')';
+ return 'GROUP_CONCAT(DISTINCT ' . $fld . ' SEPARATOR \'' . $sep . '\')';
}
}
@@ -120,9 +120,12 @@ class dba_pdo extends dba_driver {
}
}
+ // These two functions assume that postgres standard_conforming_strings is set to off;
+ // which we perform during DB open.
+
function escapebin($str) {
if($this->driver_dbtype === 'pgsql') {
- return str_replace([ chr(92), chr(0), chr(39) ], [ '\\\134', '\\\000', '\\\047' ], $str);
+ return "\\\\x" . bin2hex($str);
}
else {
return $this->escape($str);
@@ -131,7 +134,11 @@ class dba_pdo extends dba_driver {
function unescapebin($str) {
if($this->driver_dbtype === 'pgsql') {
- return stripcslashes($str);
+
+ // The initial backslash inserted by escapebin above will have been stripped
+ // by the postgres server, leaving us with '\x{hexdigits}'
+
+ return hex2bin(substr($str,2));
}
else {
return $str;