aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinclude/dba/dba_driver.php23
-rwxr-xr-xinclude/dba/dba_mysql.php2
-rwxr-xr-xinclude/dba/dba_mysqli.php2
-rwxr-xr-xinclude/dba/dba_pdo.php20
-rw-r--r--include/dba/dba_postgres.php2
5 files changed, 32 insertions, 17 deletions
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index 11a4d9011..47ec29816 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -54,7 +54,7 @@ class DBA {
self::$scheme = 'postgres';
require_once('include/dba/dba_postgres.php');
- self::$dba = new dba_postgres($server, $port, $user, $pass, $db, $install);
+ self::$dba = new dba_postgres($server, self::$scheme, $port, $user, $pass, $db, $install);
}
else {
if(!($port))
@@ -63,8 +63,7 @@ class DBA {
$server = '127.0.0.1';
require_once('include/dba/dba_pdo.php');
- self::$dba = new dba_pdo($server,$port,$user,$pass,$db,$install);
-
+ self::$dba = new dba_pdo($server,self::$scheme,$port,$user,$pass,$db,$install);
}
@@ -112,7 +111,7 @@ abstract class dba_driver {
* @param string $db database name
* @return bool
*/
- abstract function connect($server, $port, $user, $pass, $db);
+ abstract function connect($server, $scheme, $port, $user, $pass, $db);
/**
* @brief Perform a DB query with the SQL statement $sql.
@@ -146,31 +145,31 @@ abstract class dba_driver {
*/
abstract function getdriver();
- function __construct($server, $port, $user,$pass,$db,$install = false) {
- if(($install) && (! $this->install($server, $port, $user, $pass, $db))) {
+ function __construct($server, $scheme, $port, $user,$pass,$db,$install = false) {
+ if(($install) && (! $this->install($server, $scheme, $port, $user, $pass, $db))) {
return;
}
- $this->connect($server, $port, $user, $pass, $db);
+ $this->connect($server, $scheme, $port, $user, $pass, $db);
}
function get_null_date() {
- return DBA::$null_date;
+ return \DBA::$null_date;
}
function get_install_script() {
- return DBA::$install_script;
+ return \DBA::$install_script;
}
function get_table_quote() {
- return DBA::$tquot;
+ return \DBA::$tquot;
}
function utcnow() {
- return DBA::$utc_now;
+ return \DBA::$utc_now;
}
- function install($server,$user,$pass,$db) {
+ function install($server,$scheme,$port,$user,$pass,$db) {
if (!(strlen($server) && strlen($user))){
$this->connected = false;
$this->db = null;
diff --git a/include/dba/dba_mysql.php b/include/dba/dba_mysql.php
index 3cadad6dc..8b51cf578 100755
--- a/include/dba/dba_mysql.php
+++ b/include/dba/dba_mysql.php
@@ -5,7 +5,7 @@ require_once('include/dba/dba_driver.php');
class dba_mysql extends dba_driver {
- function connect($server, $port, $user,$pass,$db) {
+ function connect($server, $scheme, $port, $user,$pass,$db) {
$this->db = mysql_connect($server.":".$port,$user,$pass);
if($this->db && mysql_select_db($db,$this->db)) {
$this->connected = true;
diff --git a/include/dba/dba_mysqli.php b/include/dba/dba_mysqli.php
index afd2aa642..165c8e969 100755
--- a/include/dba/dba_mysqli.php
+++ b/include/dba/dba_mysqli.php
@@ -4,7 +4,7 @@ require_once('include/dba/dba_driver.php');
class dba_mysqli extends dba_driver {
- function connect($server,$port,$user,$pass,$db) {
+ function connect($server,$scheme,$port,$user,$pass,$db) {
if($port)
$this->db = new mysqli($server,$user,$pass,$db, $port);
else
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';
}
diff --git a/include/dba/dba_postgres.php b/include/dba/dba_postgres.php
index ae3e5a76f..560d8da60 100644
--- a/include/dba/dba_postgres.php
+++ b/include/dba/dba_postgres.php
@@ -9,7 +9,7 @@ class dba_postgres extends dba_driver {
const UTC_NOW = "now() at time zone 'UTC'";
const TQUOT = '"';
- function connect($server,$port,$user,$pass,$db) {
+ function connect($server,$scheme,$port,$user,$pass,$db) {
if(!$port) $port = 5432;
$connstr = 'host=' . $server . ' port='.$port . ' user=' . $user . ' password=' . $pass . ' dbname='. $db;
$this->db = pg_connect($connstr);