aboutsummaryrefslogtreecommitdiffstats
path: root/include/dba/dba_pdo.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-19 19:24:12 -0700
committerzotlabs <mike@macgirvin.com>2016-10-19 19:24:12 -0700
commit3726b546d5e24b2f8ffa3d02346c7a0905d3ca65 (patch)
tree9b4a76c830c81ab3d2c9c99455500d86202ed556 /include/dba/dba_pdo.php
parent2702b82bc318bde595e4afddb87e4bff300f2dd2 (diff)
downloadvolse-hubzilla-3726b546d5e24b2f8ffa3d02346c7a0905d3ca65.tar.gz
volse-hubzilla-3726b546d5e24b2f8ffa3d02346c7a0905d3ca65.tar.bz2
volse-hubzilla-3726b546d5e24b2f8ffa3d02346c7a0905d3ca65.zip
use pdo for postgres also
Diffstat (limited to 'include/dba/dba_pdo.php')
-rwxr-xr-xinclude/dba/dba_pdo.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php
index 823349f53..44de60d58 100755
--- a/include/dba/dba_pdo.php
+++ b/include/dba/dba_pdo.php
@@ -7,9 +7,9 @@ class dba_pdo extends dba_driver {
public $driver_dbtype = null;
- function connect($server,$port,$user,$pass,$db) {
+ function connect($server,$scheme,$port,$user,$pass,$db) {
- $this->driver_dbtype = 'mysql';
+ $this->driver_dbtype = $scheme;
$dns = $this->driver_dbtype
. ':host=' . $server . (is_null($port) ? '' : ';port=' . $port)
. ';dbname=' . $db;
@@ -28,6 +28,9 @@ class dba_pdo extends dba_driver {
return false;
}
+ if($this->driver_dbtype === 'postgres')
+ $this->q("SET standard_conforming_strings = 'off'; SET backslash_quote = 'on';");
+
$this->connected = true;
return true;
@@ -37,6 +40,9 @@ class dba_pdo extends dba_driver {
if((! $this->db) || (! $this->connected))
return false;
+ if($this->driver_dbtype === 'postgres' && (! strpos($sql,';')))
+ $sql .= ';';
+
$this->error = '';
$select = ((stripos($sql,'select') === 0) ? true : false);
@@ -89,6 +95,16 @@ class dba_pdo extends dba_driver {
$this->connected = false;
}
+ function concat($fld,$sep) {
+ if($this->driver_dbtype === 'postgres') {
+ return 'string_agg(' . $fld . ',\'' . $sep . '\')';
+ }
+ else {
+ return 'GROUP_CONCAT(DISTINCT '.$fld.' SEPARATOR \''.$sep.'\')';
+ }
+ }
+
+
function getdriver() {
return 'pdo';
}