From 5b7a31fe11dde8a9be9153171032991f68b4836d Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 31 Oct 2023 08:29:12 +0100 Subject: [PATCH] count rows returns 1 even with 0 as result ... --- application/models/Setup_model.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/application/models/Setup_model.php b/application/models/Setup_model.php index 79f3319e..66692014 100644 --- a/application/models/Setup_model.php +++ b/application/models/Setup_model.php @@ -3,32 +3,26 @@ class Setup_model extends CI_Model { function getCountryCount() { - $sql = 'select count(*) from dxcc_entities'; - $query = $this->db->query($sql); + $sql = 'select count(*) as count from dxcc_entities'; + $query = $this->db->query($sql); - $result = $query->result(); - - return count($result); + return $query->row()->count; } function getLogbookCount() { $userid = xss_clean($this->session->userdata('user_id')); - $sql = 'select count(*) from station_logbooks where user_id =' . $userid; - $query = $this->db->query($sql); + $sql = 'select count(*) as count from station_logbooks where user_id =' . $userid; + $query = $this->db->query($sql); - $result = $query->result(); - - return count($result); + return $query->row()->count; } function getLocationCount() { $userid = xss_clean($this->session->userdata('user_id')); - $sql = 'select count(*) from station_profile where user_id =' . $userid; - $query = $this->db->query($sql); + $sql = 'select count(*) as count from station_profile where user_id =' . $userid; + $query = $this->db->query($sql); - $result = $query->result(); - - return count($result); + return $query->row()->count; } }