Line | |
---|
1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
2 |
|
---|
3 | class 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 | return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
|
---|
29 | }
|
---|
30 |
|
---|
31 | function get_total_cardlogs($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']."%'";
|
---|
38 | }
|
---|
39 | return $this->db->query($sql)->row_array()['total'];
|
---|
40 | }
|
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.