Skip to content

Commit

Permalink
improv. add function to get db type
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcoo committed Dec 6, 2021
1 parent a77ee83 commit 7920748
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Controller/AppController.php
Expand Up @@ -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]);

Expand Down
6 changes: 6 additions & 0 deletions app/Controller/Component/UtilComponent.php
Expand Up @@ -356,5 +356,11 @@ public function getDBType()
return $this->db_type;
}

public function useSqlite() {
if (strpos(strtolower($this->getDBType()), "sqlite"))
return true;
return false;
}


}
4 changes: 2 additions & 2 deletions app/Model/Maintenance.php
Expand Up @@ -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]);
Expand Down

0 comments on commit 7920748

Please sign in to comment.