pdo testing

This commit is contained in:
zotlabs 2016-10-20 15:45:48 -07:00
parent 3726b546d5
commit b4b5eb5bab
2 changed files with 17 additions and 7 deletions

View File

@ -51,20 +51,21 @@ class DBA {
self::$install_script = 'install/schema_postgres.sql'; self::$install_script = 'install/schema_postgres.sql';
self::$utc_now = "now() at time zone 'UTC'"; self::$utc_now = "now() at time zone 'UTC'";
self::$tquot = '"'; self::$tquot = '"';
self::$scheme = 'postgres'; self::$scheme = 'pgsql';
require_once('include/dba/dba_postgres.php'); // require_once('include/dba/dba_postgres.php');
self::$dba = new dba_postgres($server, self::$scheme, $port, $user, $pass, $db, $install); // self::$dba = new dba_postgres($server, self::$scheme, $port, $user, $pass, $db, $install);
} }
else { else {
if(!($port)) if(!($port))
$port = 3306; $port = 3306;
if($server === 'localhost') if($server === 'localhost')
$server = '127.0.0.1'; $server = '127.0.0.1';
}
require_once('include/dba/dba_pdo.php'); require_once('include/dba/dba_pdo.php');
self::$dba = new dba_pdo($server,self::$scheme,$port,$user,$pass,$db,$install); self::$dba = new dba_pdo($server,self::$scheme,$port,$user,$pass,$db,$install);
}
if(is_object(self::$dba) && self::$dba->connected) { if(is_object(self::$dba) && self::$dba->connected) {

View File

@ -28,7 +28,7 @@ class dba_pdo extends dba_driver {
return false; return false;
} }
if($this->driver_dbtype === 'postgres') if($this->driver_dbtype === 'pgsql')
$this->q("SET standard_conforming_strings = 'off'; SET backslash_quote = 'on';"); $this->q("SET standard_conforming_strings = 'off'; SET backslash_quote = 'on';");
$this->connected = true; $this->connected = true;
@ -40,7 +40,7 @@ class dba_pdo extends dba_driver {
if((! $this->db) || (! $this->connected)) if((! $this->db) || (! $this->connected))
return false; return false;
if($this->driver_dbtype === 'postgres' && (! strpos($sql,';'))) if($this->driver_dbtype === 'pgsql' && (! strpos($sql,';')))
$sql .= ';'; $sql .= ';';
$this->error = ''; $this->error = '';
@ -96,7 +96,7 @@ class dba_pdo extends dba_driver {
} }
function concat($fld,$sep) { function concat($fld,$sep) {
if($this->driver_dbtype === 'postgres') { if($this->driver_dbtype === 'pgsql') {
return 'string_agg(' . $fld . ',\'' . $sep . '\')'; return 'string_agg(' . $fld . ',\'' . $sep . '\')';
} }
else { else {
@ -104,6 +104,15 @@ class dba_pdo extends dba_driver {
} }
} }
function quote_interval($txt) {
if($this->driver_dbtype === 'pgsql') {
return "'$txt'";
}
else {
return $txt;
}
}
function getdriver() { function getdriver() {
return 'pdo'; return 'pdo';