provide tools to extract a pdo constructor
This commit is contained in:
parent
894114bfbd
commit
217db8f9b2
@ -25,23 +25,31 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
|
|||||||
$dba = null;
|
$dba = null;
|
||||||
|
|
||||||
$dbtype = intval($dbtype);
|
$dbtype = intval($dbtype);
|
||||||
|
$set_port = $port;
|
||||||
|
|
||||||
if($dbtype == DBTYPE_POSTGRES) {
|
if($dbtype == DBTYPE_POSTGRES) {
|
||||||
require_once('include/dba/dba_postgres.php');
|
require_once('include/dba/dba_postgres.php');
|
||||||
if(is_null($port)) $port = 5432;
|
if(is_null($port)) $set_port = 5432;
|
||||||
$dba = new dba_postgres($server, $port, $user, $pass, $db, $install);
|
$dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install);
|
||||||
} else {
|
} else {
|
||||||
if(class_exists('mysqli')) {
|
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');
|
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 {
|
} else {
|
||||||
if (is_null($port)) $port = "3306";
|
if (is_null($port)) $set_port = "3306";
|
||||||
require_once('include/dba/dba_mysql.php');
|
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('NULL_DATE', $dba->get_null_date());
|
||||||
define('ACTIVE_DBTYPE', $dbtype);
|
define('ACTIVE_DBTYPE', $dbtype);
|
||||||
return $dba;
|
return $dba;
|
||||||
@ -60,6 +68,7 @@ abstract class dba_driver {
|
|||||||
const UTC_NOW = 'UTC_TIMESTAMP()';
|
const UTC_NOW = 'UTC_TIMESTAMP()';
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
|
protected $pdo = array();
|
||||||
|
|
||||||
public $debug = 0;
|
public $debug = 0;
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
@ -183,6 +192,15 @@ abstract class dba_driver {
|
|||||||
function unescapebin($str) {
|
function unescapebin($str) {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pdo_set($x) {
|
||||||
|
$this->pdo = $x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pdo_get() {
|
||||||
|
return $this->pdo;
|
||||||
|
}
|
||||||
|
|
||||||
} // end abstract dba_driver class
|
} // end abstract dba_driver class
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user