From d2f21e20c07f6f53aa208535fd4abb7ed1f7135e Mon Sep 17 00:00:00 2001 From: Praesidiarius Date: Mon, 12 Apr 2021 04:31:35 +0200 Subject: [PATCH] release --- CHANGELOG.md | 1 + module/Application/data/structure.sql | 2 +- .../src/Controller/CoreController.php | 62 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49442c2..517fbc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file, in reverse ## [1.0.36] - ### Added +- getCustomTable and fetchCustomTable ## [1.0.35] - 2021-04-01 diff --git a/module/Application/data/structure.sql b/module/Application/data/structure.sql index dc72cba..97a615c 100644 --- a/module/Application/data/structure.sql +++ b/module/Application/data/structure.sql @@ -145,7 +145,7 @@ ALTER TABLE `core_perfomance_log` -- CREATE TABLE `settings` ( `settings_key` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, - `settings_value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL + `settings_value` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ALTER TABLE `settings` diff --git a/module/Application/src/Controller/CoreController.php b/module/Application/src/Controller/CoreController.php index e7a90ed..078ac5a 100644 --- a/module/Application/src/Controller/CoreController.php +++ b/module/Application/src/Controller/CoreController.php @@ -433,6 +433,68 @@ public function getFormTabs() { return $aTabsByForms; } + /** + * Get Custom TableGateway + * + * @param $sTableName + * @return TableGateway + * @since 1.0.36 + */ + protected function getCustomTable($sTableName) + { + return new TableGateway($sTableName, CoreController::$oDbAdapter); + } + + /** + * Fetch Custom Table via Gateway + * + * @param string $sTableName + * @param array|object $oWhere + * @return mixed + * @since 1.0.36 + */ + protected function fetchCustomTable($sTableName,$oWhere = []) { + $oTbl = $this->getCustomTable($sTableName); + + return $oTbl->select($oWhere); + } + + /** + * Insert Data to Custom Table + * + * @param $sTableName + * @param $aData + * @return false + * @since 1.0.36 + */ + protected function insertToCustomTable($sTableName,$aData) { + $oTbl = $this->getCustomTable($sTableName); + + if($oTbl->insert($aData)) { + return $oTbl->lastInsertValue; + } else { + return false; + } + } + + /** + * Update Data in custom table + * + * @param $sTableName + * @param $aData + * @param $aWhere + * @return bool + * @since 1.0.36 + */ + protected function updateCustomTable($sTableName,$aData,$aWhere) { + $oTbl = $this->getCustomTable($sTableName); + if($oTbl->update($aData,$aWhere)) { + return true; + } else { + return false; + } + } + /** * Load all permissions based on Modules *