From 93078df1742fac249494a6f4047ebdf83c3d4710 Mon Sep 17 00:00:00 2001 From: mirzaev Date: Thu, 27 Mar 2025 09:29:24 +0700 Subject: [PATCH] resolved #24 --- mirzaev/baza/system/database.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mirzaev/baza/system/database.php b/mirzaev/baza/system/database.php index 5a9a092..27c202f 100755 --- a/mirzaev/baza/system/database.php +++ b/mirzaev/baza/system/database.php @@ -493,6 +493,8 @@ class database /** * Count * + * @throws exception_runtime If the database is corrupted (counting result is float) + * * @return int Amount of records */ public function count(): int @@ -500,8 +502,11 @@ class database // Deleting the database file cache clearstatcache(true, $this->database); - // Exit (success) - return $this->length > 0 && file_exists($this->database) ? filesize($this->database) / $this->length : 0; + // Counting + $amount = $this->length > 0 && file_exists($this->database) ? filesize($this->database) / $this->length : 0; + + // Exit (success/fail) + return is_int($amount) ? $amount : throw new exception_runtime('The database is corrupted'); } /**