From 79207481f09bafb3aea30b890f5de122d632b024 Mon Sep 17 00:00:00 2001 From: nivcoo Date: Mon, 6 Dec 2021 21:50:33 +0100 Subject: [PATCH] improv. add function to get db type --- app/Controller/AppController.php | 4 ++-- app/Controller/Component/UtilComponent.php | 6 ++++++ app/Model/Maintenance.php | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Controller/AppController.php b/app/Controller/AppController.php index c9e39dc8..2c3f8a35 100755 --- a/app/Controller/AppController.php +++ b/app/Controller/AppController.php @@ -555,9 +555,9 @@ public function __initSeoConfiguration() $get_page = []; $condition = ["'" . $current_url . "' LIKE CONCAT(page, '%')"]; - $db_type = $this->Util->getDBType(); + $use_sqlite = $this->Util->useSqlite(); - if (strpos(strtolower($db_type), "sqlite")) + if ($use_sqlite) $condition = ["'" . $current_url . "' LIKE 'page' || '%' "]; $check = $this->Seo->find('all', ['conditions' => $condition]); diff --git a/app/Controller/Component/UtilComponent.php b/app/Controller/Component/UtilComponent.php index 70ae950b..55c64946 100755 --- a/app/Controller/Component/UtilComponent.php +++ b/app/Controller/Component/UtilComponent.php @@ -356,5 +356,11 @@ public function getDBType() return $this->db_type; } + public function useSqlite() { + if (strpos(strtolower($this->getDBType()), "sqlite")) + return true; + return false; + } + } diff --git a/app/Model/Maintenance.php b/app/Model/Maintenance.php index 2bc0a732..e711b868 100644 --- a/app/Model/Maintenance.php +++ b/app/Model/Maintenance.php @@ -4,11 +4,11 @@ class Maintenance extends AppModel { function checkMaintenance($url, $utilComponent) { - $db_type = $utilComponent->getDBType(); + $use_sqlite = $utilComponent->useSqlite(); $condition = ["'" . $url . "' LIKE CONCAT(Maintenance.url, '%')", "active" => 1]; - if (strpos(strtolower($db_type), "sqlite")) + if ($use_sqlite) $condition = ["'" . $url . "' LIKE 'Maintenance.url' || '%')", "active" => 1]; $check = $this->find("first", ["conditions" => $condition]);