fixed pg/mys compatibility
This commit is contained in:
parent
15b06ce56e
commit
16fa6a5f15
@ -42,7 +42,7 @@ class Api {
|
|||||||
private $m_verifyclass = null;
|
private $m_verifyclass = null;
|
||||||
private $m_apiclass = null;
|
private $m_apiclass = null;
|
||||||
|
|
||||||
public function __construct(\SYSTEM\verifyclass $VerifyClass, \SYSTEM\API\apiclass $ApiClass,$DBInfo = null){
|
public function __construct(\SYSTEM\verifyclass $VerifyClass, \SYSTEM\API\apiclass $ApiClass,$DBInfo = null){
|
||||||
$this->m_dbinfo = $DBInfo == null ? \SYSTEM\system::getSystemDBInfo() : $DBInfo;
|
$this->m_dbinfo = $DBInfo == null ? \SYSTEM\system::getSystemDBInfo() : $DBInfo;
|
||||||
$this->m_verifyclass = $VerifyClass;
|
$this->m_verifyclass = $VerifyClass;
|
||||||
$this->m_apiclass = $ApiClass;
|
$this->m_apiclass = $ApiClass;
|
||||||
@ -139,7 +139,7 @@ class Api {
|
|||||||
private function getApiTree(){
|
private function getApiTree(){
|
||||||
|
|
||||||
$con = new \SYSTEM\DB\Connection($this->m_dbinfo);
|
$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);
|
unset($con);
|
||||||
|
|
||||||
if(!$res){
|
if(!$res){
|
||||||
|
|||||||
@ -4,7 +4,8 @@ namespace SYSTEM\DBD;
|
|||||||
|
|
||||||
class APITable {
|
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_ID = 'ID';
|
||||||
const FIELD_FLAG = 'flag';
|
const FIELD_FLAG = 'flag';
|
||||||
|
|||||||
@ -4,7 +4,8 @@ namespace SYSTEM\DBD;
|
|||||||
|
|
||||||
class PAGETable {
|
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_ID = 'ID';
|
||||||
const FIELD_FLAG = 'flag';
|
const FIELD_FLAG = 'flag';
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
namespace SYSTEM\DBD;
|
namespace SYSTEM\DBD;
|
||||||
|
|
||||||
class locale_string {
|
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_ID = 'id';
|
||||||
const FIELD_CATEGORY = 'category';
|
const FIELD_CATEGORY = 'category';
|
||||||
|
|||||||
@ -119,7 +119,7 @@ class PageApi {
|
|||||||
private function getPageTree(){
|
private function getPageTree(){
|
||||||
|
|
||||||
$con = new \SYSTEM\DB\Connection($this->m_dbinfo);
|
$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){
|
if(!$res){
|
||||||
throw new \SYSTEM\LOG\ERROR("Database Error ". pg_last_error());}
|
throw new \SYSTEM\LOG\ERROR("Database Error ". pg_last_error());}
|
||||||
|
|||||||
@ -52,29 +52,29 @@ class locale {
|
|||||||
foreach($request as $strid){
|
foreach($request as $strid){
|
||||||
if(!\preg_match("^[a-zA-Z0-9_]+$^", $strid) != 0){
|
if(!\preg_match("^[a-zA-Z0-9_]+$^", $strid) != 0){
|
||||||
throw new \Exception("Requested id contains inpropper symbols: ".$strid);}
|
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);
|
$where = substr($where,2);
|
||||||
|
|
||||||
$con = new \SYSTEM\DB\Connection(new \DBD\dasensePostgres());
|
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||||
$res = $con->prepare( 'localeArrStmt', 'SELECT "'.$lang.'","'.\DBD\SYSTEM\locale_string::FIELD_ID.'" FROM '.\DBD\SYSTEM\locale_string::NAME.' WHERE '.$where,
|
$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);
|
$request);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
while($r = $res->next()){
|
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;
|
return $result;
|
||||||
} else if(\intval($request)){
|
} else if(\intval($request)){
|
||||||
$cat = \intval($request);
|
$cat = \intval($request);
|
||||||
|
|
||||||
$con = new \SYSTEM\DB\Connection(new \DBD\dasensePostgres());
|
$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));
|
array($cat));
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
while($r = $res->next()){
|
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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,4 +31,7 @@ class system {
|
|||||||
\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_PORT));
|
\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