source: pro-violet-viettel/sourcecode/application/modules/admin/models/cardlog_model.php @ 757

Last change on this file since 757 was 579, checked in by dungnv, 10 years ago
File size: 1.1 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class Cardlog_model extends MY_Model
4{
5       
6        protected $table_name = 'tblcardlog';
7        protected $id_name = 'id';
8
9        function __construct()
10        {
11                parent::__construct();
12        }
13
14        function get_cardlogs($data)
15        {
16                $sql = "SELECT * FROM " . $this->table_name;
17                if ($data['keyword'])
18                {
19                        $sql.=" WHERE (sender LIKE '%".$data['keyword']."%'";
20                }
21                $order = "";
22                if ($data['sorting_order'] != "sorting") {
23                        $sort = "DESC";
24                        if ($data['sorting_order'] == "sorting_asc")
25                                $sort = "ASC";
26                        $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
27                }
28                $query = $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ");
29                return $query->result_array();
30        }
31       
32        function get_total_cardlogs($data)
33        {
34                $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
35                if (isset($data['keyword']))
36                {
37                        if (strlen($data['keyword'])>0)
38                                $sql.=" WHERE (sender LIKE '%".$data['keyword']."%'";
39                }
40                $query = $this->db->query($sql);
41                $row = $query->row_array();
42                return $row['total'];
43        }
44}
Note: See TracBrowser for help on using the repository browser.