more qqs for SAIMOD_LOCALE

This commit is contained in:
Ulf Gebhardt 2014-05-11 17:16:02 +02:00
parent c8a2a0b15b
commit 029d90c0bc
7 changed files with 67 additions and 48 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_LOCALE_ADD extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'INSERT INTO '.\SYSTEM\DBD\system_locale_string::NAME_PG.' (id, category) VALUES ($1, $2);',
//mys
'INSERT INTO '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' (id, category) VALUES (?, ?);'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_LOCALE_CATEGORY extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT "category", COUNT(*) as "count" FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' GROUP BY "category" ORDER BY "category" ASC;',
//mys
'SELECT `category`, COUNT(*) as `count` FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' GROUP BY `category` ORDER BY `category` ASC;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_LOCALE_DEL extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'DELETE FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' WHERE id=$1;',
//mys
'DELETE FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' WHERE id=?;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_LOCALE_ID extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' WHERE id = $1 ORDER BY "category" ASC;',
//mys
'SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' WHERE id = ? ORDER BY "category" ASC;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_LOCALE_SELECT extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' ORDER BY "category" ASC;',
//mys
'SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' ORDER BY category ASC;'
);}}

View File

@ -5,7 +5,7 @@ System - PHP Framework
License License
======= =======
Copyright (c) 2013 TU-Darmstadt, Ulf Gebhardt Copyright (c) 2013-2014 Ulf Gebhardt
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -10,12 +10,7 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){ public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){
$vars = array(); $vars = array();
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); $res = \SYSTEM\DBD\SYS_SAIMOD_LOCALE_CATEGORY::QQ();
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT "category", COUNT(*) as "count" FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' GROUP BY "category" ORDER BY "category" ASC;');
} else {
$res = $con->query('SELECT `category`, COUNT(*) as `count` FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' GROUP BY `category` ORDER BY `category` ASC;');
}
$vars['tabopts'] = ''; $vars['tabopts'] = '';
$first = true; $first = true;
@ -26,18 +21,13 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/tabopt.tpl'), $vars2); $vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/tabopt.tpl'), $vars2);
} }
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' ORDER BY "category" ASC;');
} else {
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' ORDER BY category ASC;');
}
$langhead = ''; $langhead = '';
foreach (self::getLanguages() as $lang){ foreach (self::getLanguages() as $lang){
$langhead .= '<th>'.$lang.'</th>'; $langhead .= '<th>'.$lang.'</th>';
$languages[] = $lang; $languages[] = $lang;
} }
$res = \SYSTEM\DBD\SYS_SAIMOD_LOCALE_SELECT::QQ();
$tabs = array(); $tabs = array();
while($r = $res->next()){ while($r = $res->next()){
$tabs[$r['category']]['tab_id'] = $r['category']; $tabs[$r['category']]['tab_id'] = $r['category'];
@ -74,44 +64,18 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
} }
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_add($id, $category){ public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_add($id, $category){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); return \SYSTEM\DBD\SYS_SAIMOD_LOCALE_ADD::QI(array($id, $category)) ? \SYSTEM\LOG\JsonResult::ok() : \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no data added"));}
$res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare('addText' ,'INSERT INTO '.\SYSTEM\DBD\system_locale_string::NAME_PG.' (id, category) VALUES ($1, $2);', array($id, $category));
} else {
$res = $con->prepare('addText' ,'INSERT INTO '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' (id, category) VALUES (?, ?);', array($id, $category));
}
return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no data added")) : \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_addmode(){ public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_addmode(){
$vars = array(); $vars = array();
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/add.tpl'), $vars); return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/add.tpl'), $vars);}
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_delete($id){ public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_delete($id){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); return \SYSTEM\DBD\SYS_SAIMOD_LOCALE_DEL::QI(array($id)) ? \SYSTEM\LOG\JsonResult::ok() : \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("could not delete the permitted data"));}
$res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare('deleteText' ,'DELETE FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' WHERE id=$1;', array($id));
} else {
$res = $con->prepare('deleteText' ,'DELETE FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' WHERE id=?;', array($id));
}
return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("could not delete the permitted data")) : \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_editmode($entry){ public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_action_editmode($entry){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); $r = \SYSTEM\DBD\SYS_SAIMOD_LOCALE_ID::Q1(array($entry));
$res = null; if(!$r){
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare( 'edit',
'SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_PG.' WHERE id = $1 ORDER BY "category" ASC;',
array($entry));
} else {
$res = $con->prepare( 'edit',
'SELECT * FROM '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' WHERE id = ? ORDER BY "category" ASC;',
array($entry));
}
if(!$r = $res->next()){
throw new \SYSTEM\LOG\ERROR("No such Entry found!");} throw new \SYSTEM\LOG\ERROR("No such Entry found!");}
$vars = array(); $vars = array();