From 4268a703885ab99de2b547d84136fe12b8c35112 Mon Sep 17 00:00:00 2001 From: Joshua Fernandes Date: Tue, 30 May 2017 07:36:57 +0530 Subject: [PATCH] fix for that issue both display and count --- application/models/Giftcard.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application/models/Giftcard.php b/application/models/Giftcard.php index c57a5319a..e2266b79c 100644 --- a/application/models/Giftcard.php +++ b/application/models/Giftcard.php @@ -18,9 +18,12 @@ class Giftcard extends CI_Model */ public function get_max_number() { - $this->db->select_max('giftcard_number'); + $this->db->select('cast(giftcard_number AS UNSIGNED) AS giftcard_number'); $this->db->from('giftcards'); $this->db->where('giftcard_number REGEXP', "'^[0-9]+$'", FALSE); + $this->db->order_by("giftcard_number","desc"); + $this->db->limit(1); + return $this->db->get()->row(); } @@ -108,7 +111,7 @@ class Giftcard extends CI_Model { if($this->db->insert('giftcards', $giftcard_data)) { - $giftcard_data['giftcard_id'] = $this->db->insert_id(); + $giftcard_data['giftcard_number'] = $this->db->insert_id(); return TRUE; }