2019-11-03 18:23:06 +00:00
|
|
|
<?php
|
|
|
|
class ClassConfig implements InterfacePostgreSQL, InterfaceConfig {
|
|
|
|
private $_urlRewrite = false;
|
|
|
|
|
|
|
|
public function __construct(){}
|
|
|
|
public function __destruct(){}
|
|
|
|
|
2020-11-26 13:24:16 +00:00
|
|
|
public static function databaseConnect(){
|
2019-11-03 18:23:06 +00:00
|
|
|
try {
|
|
|
|
$oPDOLink = new PDO("pgsql:host=".InterfacePostgreSQL::PG_SERVER.";port=".InterfacePostgreSQL::PG_PORT.";dbname=".InterfacePostgreSQL::PG_DBNAME.";user=".InterfacePostgreSQL::PG_USER.";password=".InterfacePostgreSQL::PG_PASSWORD); //, array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8")
|
|
|
|
return $oPDOLink;
|
|
|
|
} catch( PDOException $Exception ) {
|
|
|
|
// PHP Fatal Error. Second Argument Has To Be An Integer, But PDOException::getCode Returns A
|
|
|
|
// String.
|
|
|
|
//throw new MyDatabaseException( $Exception->getMessage( ) , (int)$Exception->getCode( ) );
|
|
|
|
echo($Exception->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function foreignDatabaseConnect($host=InterfacePostgreSQL::PG_FOREIGN_SERVER,
|
|
|
|
$dbname=InterfacePostgreSQL::PG_FOREIGN_DBNAME,
|
|
|
|
$user=InterfacePostgreSQL::PG_FOREIGN_USER,
|
|
|
|
$password=InterfacePostgreSQL::PG_FOREIGN_PASSWORD
|
|
|
|
){
|
|
|
|
try {
|
|
|
|
$oPDOLink = new PDO("pgsql:host=".$host.";dbname=".$dbname.";user=".$user.";password=".$password); //, array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8")
|
|
|
|
return $oPDOLink;
|
|
|
|
} catch( PDOException $Exception ) {
|
|
|
|
// PHP Fatal Error. Second Argument Has To Be An Integer, But PDOException::getCode Returns A
|
|
|
|
// String.
|
|
|
|
//throw new MyDatabaseException( $Exception->getMessage( ) , (int)$Exception->getCode( ) );
|
|
|
|
echo($Exception->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-26 13:24:16 +00:00
|
|
|
public function getURLRoot($post_url=''){
|
|
|
|
$this->_postURL=$post_url;
|
|
|
|
return ($this->_postURL!='')?InterfaceConfig::URL_ROOT.$this->_postURL:InterfaceConfig::URL_ROOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPathRoot($post_url=''){
|
|
|
|
$this->_postURL=$post_url;
|
|
|
|
return ($this->_postURL!='')?InterfaceConfig::PATH_ROOT.$this->_postURL:InterfaceConfig::PATH_ROOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPathCustom($post_url=''){
|
|
|
|
$this->_postURL=$post_url;
|
|
|
|
return ($this->_postURL!='')?InterfaceConfig::PATH_CUSTOM.$this->_postURL:InterfaceConfig::PATH_CUSTOM;
|
|
|
|
}
|
2019-11-03 18:23:06 +00:00
|
|
|
|
|
|
|
public function getURLScript($post_url=''){
|
|
|
|
$this->_postURL=$post_url;
|
|
|
|
return ($this->_postURL!='')?InterfaceConfig::URL_SCRIPT.$this->_postURL:InterfaceConfig::URL_SCRIPT;
|
|
|
|
}
|
|
|
|
|
2020-11-26 13:24:16 +00:00
|
|
|
|
2019-11-03 18:23:06 +00:00
|
|
|
public function getConfig(){
|
|
|
|
$oPDOLink = ClassConfig::databaseConnect();
|
|
|
|
$rowsConfig = array();
|
|
|
|
$sql="
|
|
|
|
SELECT *
|
|
|
|
FROM core_config
|
|
|
|
WHERE is_active=TRUE
|
|
|
|
";
|
|
|
|
$execSQL = $oPDOLink->prepare($sql);
|
|
|
|
$execSQL->execute(array());
|
|
|
|
$rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
foreach($rows as $k=>$v){
|
|
|
|
$rowsConfig[$rows[$k]['k']] = $rows[$k]['v'];
|
|
|
|
}
|
|
|
|
return $rowsConfig;
|
|
|
|
}
|
|
|
|
}
|