From f0f862d9795a22ca7f0f4c3f8e735ca8280076ab Mon Sep 17 00:00:00 2001 From: User Date: Tue, 10 Oct 2023 15:02:59 +0300 Subject: [PATCH] 20231010#2 --- src/Mysql/MysqlStorage.php | 9 +++++++-- src/Mysql/MysqlStorageData.php | 1 + src/Mysql/MysqlStorageInterface.php | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Mysql/MysqlStorage.php b/src/Mysql/MysqlStorage.php index 1efbcec..2e9c945 100644 --- a/src/Mysql/MysqlStorage.php +++ b/src/Mysql/MysqlStorage.php @@ -107,10 +107,12 @@ class MysqlStorage implements MysqlStorageInterface { } /** @inheritDoc */ - public function read(string $sql, int $ln = 0, int $numPage = 1) : bool|MysqlStorageData { + public function read(string $sql, int $ln=0, int $numPage=1, int $count=0): bool|MysqlStorageData { + if ($ln > 1) { - $cnts = $this->query($sql)->num_rows; + $cnts = (!empty($count)) ? $count : $this->query($sql)->num_rows; } + // часть строки запроса с лимит switch (true){ case ($ln > 1 || $numPage > 1) : $limit = " limit ".(($numPage * $ln) - $ln).", ".$ln; break; @@ -123,9 +125,12 @@ class MysqlStorage implements MysqlStorageInterface { $data = new MysqlStorageData($result); $data->count = $cnts ?? 0; + $data->hex = md5($sql); return $data; } + + /** @inheritDoc */ public function chktbl(string $tbl) : bool { $result = $this->mysqli->query("SHOW TABLES LIKE '".$this->escapeStr($tbl)."'"); diff --git a/src/Mysql/MysqlStorageData.php b/src/Mysql/MysqlStorageData.php index 69708ba..e382802 100644 --- a/src/Mysql/MysqlStorageData.php +++ b/src/Mysql/MysqlStorageData.php @@ -8,6 +8,7 @@ class MysqlStorageData { private ?\mysqli_result $result; private array $arrayData = []; public int $count; + public string $hex = ""; /** * MysqlDataObject constructor. diff --git a/src/Mysql/MysqlStorageInterface.php b/src/Mysql/MysqlStorageInterface.php index 00c3b53..3be55f3 100644 --- a/src/Mysql/MysqlStorageInterface.php +++ b/src/Mysql/MysqlStorageInterface.php @@ -57,7 +57,7 @@ interface MysqlStorageInterface { * @param int $count * @return bool|MysqlStorageData */ - public function read(string $sql, int $ln = 0, int $numPage = 1) : bool|MysqlStorageData; + public function read(string $sql, int $ln = 0, int $numPage = 1, int $count=0) : bool|MysqlStorageData; /** * @param string $tbl