source: pro-violet-viettel/sourcecode/application/modules/admin/models/smslog_model.php @ 610

Last change on this file since 610 was 579, checked in by dungnv, 10 years ago
File size: 1.3 KB
RevLine 
[426]1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[328]2
3class Smslog_model extends MY_Model
4{
5       
6        protected $table_name = 'tblsmslog';
7        protected $id_name = 'id';
8
9        function __construct()
10        {
11                parent::__construct();
12        }
13       
[426]14        function get_smslogs($data)
15        {
16                $sql = "SELECT * FROM " . $this->table_name;
17                if ($data['keyword'])
18                {
19                        $sql.=" WHERE (sender LIKE '%".$data['keyword']."%' OR mobody LIKE '%".$data['keyword']."%' OR mtbody 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                }
[579]28               
29                $query = $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ");
30               
31                return $query->result_array();
[426]32        }
33       
34        function get_total_smslogs($data)
35        {
36                $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
37                if (isset($data['keyword']))
38                {
39                        if (strlen($data['keyword'])>0)
40                                $sql.=" WHERE (sender LIKE '%".$data['keyword']."%' OR mobody LIKE '%".$data['keyword']."%' OR mtbody LIKE '%".$data['keyword']."%') ";
41                }
[579]42               
43                $query =  $this->db->query($sql);
44                $row = $query->row_array();
45                return $row['total'];
[426]46        }
[328]47}
Note: See TracBrowser for help on using the repository browser.