From b8d69991f0ad9c3611ca04b10a80138826e00c15 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Wed, 6 Jul 2022 19:24:23 +0300 Subject: [PATCH] [*] MQ DB where fix --- core/lib/Core/Models/DB.class.php | 7 ++++--- core/lib/Core/Models/MQ.class.php | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/lib/Core/Models/DB.class.php b/core/lib/Core/Models/DB.class.php index 3fd8954..14bad6b 100644 --- a/core/lib/Core/Models/DB.class.php +++ b/core/lib/Core/Models/DB.class.php @@ -77,7 +77,7 @@ * * @return string */ - public function createWhere($where, $logic = 'AND'): string + public function createWhere($where, string $logic = 'AND'): string { if (!is_array($where)) { return $where; @@ -99,9 +99,10 @@ } else { $symbol = '='; } - $where_string = $where_string . ' (' . $where_key . $symbol . '\'' . $where_item . '\') ' . $logic; + $where_string = $where_string . ' ' . $where_key . $symbol . '\'' . $where_item . '\' ' . $logic; } - return substr($where_string, 0, -4); + $offset = (strlen($logic) + 1); + return substr($where_string, 0, -$offset); } /** diff --git a/core/lib/Core/Models/MQ.class.php b/core/lib/Core/Models/MQ.class.php index 2af8587..9ae183a 100644 --- a/core/lib/Core/Models/MQ.class.php +++ b/core/lib/Core/Models/MQ.class.php @@ -327,7 +327,6 @@ public function removeTask(?int $taskId = null): bool { if (empty($taskId)) { - SystemFunctions::sendTelegram('Не передан идентификатор задания (' . $taskId . ')' . PHP_EOL . print_r(func_get_args(), true)); throw new CoreException('Не передан идентификатор задания'); } return $this->DB->remove(self::TABLE, ['id' => $taskId]);