From 6caceefc176378eb543a6db738b19f2324460a07 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 6 Apr 2024 01:43:19 +0300 Subject: [PATCH] 20240406#2 --- src/Mysql/MysqlStorage.php | 3 ++- src/Mysql/MysqlStorageInterface.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Mysql/MysqlStorage.php b/src/Mysql/MysqlStorage.php index e10d1b0..c194bc8 100644 --- a/src/Mysql/MysqlStorage.php +++ b/src/Mysql/MysqlStorage.php @@ -135,8 +135,9 @@ class MysqlStorage implements MysqlStorageInterface { } /** @inheritDoc */ - public function findOne(string $sql) : array { + public function findOne(string $sql) : bool|array { $result = $this->query($sql); + if (!$result || $result->num_rows == 0) return false; $data = new MysqlStorageData($result); return $data->fetchOne(); } diff --git a/src/Mysql/MysqlStorageInterface.php b/src/Mysql/MysqlStorageInterface.php index 478aebe..42b9a93 100644 --- a/src/Mysql/MysqlStorageInterface.php +++ b/src/Mysql/MysqlStorageInterface.php @@ -86,7 +86,7 @@ interface MysqlStorageInterface { * @param string $sql * @return array */ - public function findOne(string $sql) : array; + public function findOne(string $sql) : bool|array; /** * Метод экранирования данных с учетом текущего подключения в т.ч для LIKE