aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-15 19:16:55 -0700
committerredmatrix <git@macgirvin.com>2016-05-15 19:16:55 -0700
commit217db8f9b2050510d2d2f2679d325d60d90cdb93 (patch)
tree096d68e161bd5774201d6e617bb43d428540ae63 /include
parent894114bfbdb31f9678837c7e1a234638afba3ca5 (diff)
downloadvolse-hubzilla-217db8f9b2050510d2d2f2679d325d60d90cdb93.tar.gz
volse-hubzilla-217db8f9b2050510d2d2f2679d325d60d90cdb93.tar.bz2
volse-hubzilla-217db8f9b2050510d2d2f2679d325d60d90cdb93.zip
provide tools to extract a pdo constructor
Diffstat (limited to 'include')
-rwxr-xr-xinclude/dba/dba_driver.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index 8e205a4aa..4a1752672 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -25,23 +25,31 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
$dba = null;
$dbtype = intval($dbtype);
+ $set_port = $port;
if($dbtype == DBTYPE_POSTGRES) {
require_once('include/dba/dba_postgres.php');
- if(is_null($port)) $port = 5432;
- $dba = new dba_postgres($server, $port, $user, $pass, $db, $install);
+ if(is_null($port)) $set_port = 5432;
+ $dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install);
} else {
if(class_exists('mysqli')) {
- if (is_null($port)) $port = ini_get("mysqli.default_port");
+ if (is_null($port)) $set_port = ini_get("mysqli.default_port");
require_once('include/dba/dba_mysqli.php');
- $dba = new dba_mysqli($server, $port,$user,$pass,$db,$install);
+ $dba = new dba_mysqli($server, $set_port,$user,$pass,$db,$install);
} else {
- if (is_null($port)) $port = "3306";
+ if (is_null($port)) $set_port = "3306";
require_once('include/dba/dba_mysql.php');
- $dba = new dba_mysql($server, $port,$user,$pass,$db,$install);
+ $dba = new dba_mysql($server, $set_port,$user,$pass,$db,$install);
}
}
+ if(is_object($dba) && $dba->connected) {
+ $dns = (($dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql')
+ . ':host=' . $server . (is_null($port) ? '' : ';port=' . $port)
+ . ';dbname=' . $db;
+ $dba->pdo_set(array($dns,$user,$pass));
+ }
+
define('NULL_DATE', $dba->get_null_date());
define('ACTIVE_DBTYPE', $dbtype);
return $dba;
@@ -60,6 +68,7 @@ abstract class dba_driver {
const UTC_NOW = 'UTC_TIMESTAMP()';
protected $db;
+ protected $pdo = array();
public $debug = 0;
public $connected = false;
@@ -183,6 +192,15 @@ abstract class dba_driver {
function unescapebin($str) {
return $str;
}
+
+ function pdo_set($x) {
+ $this->pdo = $x;
+ }
+
+ function pdo_get() {
+ return $this->pdo;
+ }
+
} // end abstract dba_driver class