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

Last change on this file since 464 was 426, checked in by namnd, 11 years ago
File size: 1.2 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                }
28                return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
29        }
30       
31        function get_total_smslogs($data)
32        {
33                $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
34                if (isset($data['keyword']))
35                {
36                        if (strlen($data['keyword'])>0)
37                                $sql.=" WHERE (sender LIKE '%".$data['keyword']."%' OR mobody LIKE '%".$data['keyword']."%' OR mtbody LIKE '%".$data['keyword']."%') ";
38                }
39                return $this->db->query($sql)->row_array()['total'];
40        }
[328]41}
Note: See TracBrowser for help on using the repository browser.