fixed pg/mys compatibility
This commit is contained in:
parent
15b06ce56e
commit
16fa6a5f15
@ -139,7 +139,7 @@ class Api {
|
||||
private function getApiTree(){
|
||||
|
||||
$con = new \SYSTEM\DB\Connection($this->m_dbinfo);
|
||||
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\APITable::NAME.' ORDER BY "'.\SYSTEM\DBD\APITable::FIELD_ID.'"');
|
||||
$res = $con->query('SELECT * FROM '.(\SYSTEM\system::isSystemDbInfoPG() ? \SYSTEM\DBD\APITable::NAME_PG : \SYSTEM\DBD\APITable::NAME_MYS).' ORDER BY "'.\SYSTEM\DBD\APITable::FIELD_ID.'"');
|
||||
unset($con);
|
||||
|
||||
if(!$res){
|
||||
|
||||
@ -4,7 +4,8 @@ namespace SYSTEM\DBD;
|
||||
|
||||
class APITable {
|
||||
|
||||
const NAME = 'system_api_calls';
|
||||
const NAME_PG = 'system.api_calls';
|
||||
const NAME_MYS = 'system_api_calls';
|
||||
|
||||
const FIELD_ID = 'ID';
|
||||
const FIELD_FLAG = 'flag';
|
||||
|
||||
@ -4,7 +4,8 @@ namespace SYSTEM\DBD;
|
||||
|
||||
class PAGETable {
|
||||
|
||||
const NAME = 'system_page_calls';
|
||||
const NAME_PG = 'system.page_calls';
|
||||
const NAME_MYS = 'system_page_calls';
|
||||
|
||||
const FIELD_ID = 'ID';
|
||||
const FIELD_FLAG = 'flag';
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class locale_string {
|
||||
const NAME = 'system_locale_string';
|
||||
const NAME_PG = 'system.locale_string';
|
||||
const NAME_MYS = 'system_locale_string';
|
||||
|
||||
const FIELD_ID = 'id';
|
||||
const FIELD_CATEGORY = 'category';
|
||||
|
||||
@ -119,7 +119,7 @@ class PageApi {
|
||||
private function getPageTree(){
|
||||
|
||||
$con = new \SYSTEM\DB\Connection($this->m_dbinfo);
|
||||
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\PAGETable::NAME.' ORDER BY "'.\SYSTEM\DBD\PAGETable::FIELD_ID.'"');
|
||||
$res = $con->query('SELECT * FROM '.(\SYSTEM\system::isSystemDbInfoPG() ? \SYSTEM\DBD\PAGETable::NAME_PG : \SYSTEM\DBD\PAGETable::NAME_MYS).' ORDER BY "'.\SYSTEM\DBD\PAGETable::FIELD_ID.'"');
|
||||
|
||||
if(!$res){
|
||||
throw new \SYSTEM\LOG\ERROR("Database Error ". pg_last_error());}
|
||||
|
||||
@ -52,29 +52,29 @@ class locale {
|
||||
foreach($request as $strid){
|
||||
if(!\preg_match("^[a-zA-Z0-9_]+$^", $strid) != 0){
|
||||
throw new \Exception("Requested id contains inpropper symbols: ".$strid);}
|
||||
$where .= 'OR "'.\DBD\SYSTEM\locale_string::FIELD_ID.'" = $1 ';
|
||||
$where .= 'OR "'.\SYSTEM\DBD\locale_string::FIELD_ID.'" = $1 ';
|
||||
}
|
||||
$where = substr($where,2);
|
||||
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\dasensePostgres());
|
||||
$res = $con->prepare( 'localeArrStmt', 'SELECT "'.$lang.'","'.\DBD\SYSTEM\locale_string::FIELD_ID.'" FROM '.\DBD\SYSTEM\locale_string::NAME.' WHERE '.$where,
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$res = $con->prepare( 'localeArrStmt', 'SELECT "'.$lang.'","'.\SYSTEM\DBD\locale_string::FIELD_ID.'" FROM '.(\SYSTEM\system::isSystemDbInfoPG() ? \SYSTEM\DBD\locale_string::NAME_PG : \SYSTEM\DBD\locale_string::NAME_MYS).' WHERE '.$where,
|
||||
$request);
|
||||
|
||||
$result = array();
|
||||
while($r = $res->next()){
|
||||
$result[$r[\DBD\SYSTEM\locale_string::FIELD_ID]] = $r[$lang];}
|
||||
$result[$r[\SYSTEM\DBD\locale_string::FIELD_ID]] = $r[$lang];}
|
||||
|
||||
return $result;
|
||||
} else if(\intval($request)){
|
||||
$cat = \intval($request);
|
||||
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\dasensePostgres());
|
||||
$res = $con->prepare( 'localeStmt', 'SELECT "'.$lang.'","'.\DBD\SYSTEM\locale_string::FIELD_ID.'" FROM '.\DBD\SYSTEM\locale_string::NAME.' WHERE '.\DBD\SYSTEM\locale_string::FIELD_CATEGORY.' = $1;',
|
||||
$res = $con->prepare( 'localeStmt', 'SELECT "'.$lang.'","'.\SYSTEM\DBD\locale_string::FIELD_ID.'" FROM '.(\SYSTEM\system::isSystemDbInfoPG() ? \SYSTEM\DBD\locale_string::NAME_PG : \SYSTEM\DBD\locale_string::NAME_MYS).' WHERE '.\SYSTEM\DBD\locale_string::FIELD_CATEGORY.' = $1;',
|
||||
array($cat));
|
||||
|
||||
$result = array();
|
||||
while($r = $res->next()){
|
||||
$result[$r[\DBD\SYSTEM\locale_string::FIELD_ID]] = $r[$lang];}
|
||||
$result[$r[\SYSTEM\DBD\locale_string::FIELD_ID]] = $r[$lang];}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -31,4 +31,7 @@ class system {
|
||||
\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_PORT));
|
||||
}
|
||||
}
|
||||
|
||||
public static function isSystemDbInfoPG(){
|
||||
return (\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_TYPE) == \SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_TYPE_PG);}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user