Line | |
---|
1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
2 |
|
---|
3 | class User_model extends MY_Model
|
---|
4 | {
|
---|
5 |
|
---|
6 | protected $table_name = 'tbluser';
|
---|
7 | protected $id_name = 'us_id';
|
---|
8 |
|
---|
9 | function __construct()
|
---|
10 | {
|
---|
11 | parent::__construct();
|
---|
12 | }
|
---|
13 |
|
---|
14 | function check_data($login_name)
|
---|
15 | {
|
---|
16 | $this->db->where('login_name', $login_name);
|
---|
17 | $query = $this->db->get($this->table_name);
|
---|
18 | return $query->num_rows();
|
---|
19 | }
|
---|
20 |
|
---|
21 | function get_list_users($data)
|
---|
22 | {
|
---|
23 | $sql="SELECT * FROM ".$this->table_name;
|
---|
24 | if ($data['keyword'])
|
---|
25 | {
|
---|
26 | $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
|
---|
27 | }
|
---|
28 | $order = "";
|
---|
29 | if ($data['sorting_order'] != "sorting") {
|
---|
30 | $sort = "DESC";
|
---|
31 | if ($data['sorting_order'] == "sorting_asc")
|
---|
32 | $sort = "ASC";
|
---|
33 | $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
|
---|
34 | }
|
---|
35 | return $this->db->query($sql." ORDER BY us_id DESC LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
|
---|
36 | }
|
---|
37 |
|
---|
38 | function get_total_users($data)
|
---|
39 | {
|
---|
40 | $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
|
---|
41 | if (isset($data['keyword']))
|
---|
42 | {
|
---|
43 | $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
|
---|
44 | }
|
---|
45 | return $this->db->query($sql)->row_array()['total'];
|
---|
46 | }
|
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.