From 8ce7cb67909b5c27eb4b21c995ccf1e052f46c9f Mon Sep 17 00:00:00 2001 From: Rei Yan Date: Mon, 18 Oct 2021 02:13:15 +0700 Subject: [PATCH] feat: add count --- core/functions/common.php | 3 ++- core/libraries/DB.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/functions/common.php b/core/functions/common.php index 3251c18..db47883 100644 --- a/core/functions/common.php +++ b/core/functions/common.php @@ -53,10 +53,11 @@ function assets($files) } function dd($data){ + $data = var_dump($data); highlight_string(""); echo ''; die(); - } +} function debug($var,$show = false) { if($show) { $dis = 'block'; }else { $dis = 'none'; } diff --git a/core/libraries/DB.php b/core/libraries/DB.php index a5ce13b..0474250 100644 --- a/core/libraries/DB.php +++ b/core/libraries/DB.php @@ -428,4 +428,20 @@ private function _gettype($var) if (is_int($var)) return 'i'; return 'b'; } + + /** + * Get the number of records in the result set + * @return int + */ + /** + * @method count + * + * Used to get the number of records in the result set + * + * example: + * + */ + public function count() { + return count($this->query($this->sql)->fetchAll()); + } }