Rev | Line | |
---|
[369] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
[328] | 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 | }
|
---|
[369] | 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 | }
|
---|
[375] | 20 |
|
---|
| 21 | function get_list_users($data)
|
---|
| 22 | {
|
---|
| 23 | $sql="SELECT * FROM ".$this->table_name;
|
---|
| 24 | $data['keyword']='';
|
---|
| 25 | if ($data['keyword'])
|
---|
| 26 | {
|
---|
| 27 | $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
|
---|
| 28 | }
|
---|
| 29 | return $this->db->query($sql." ORDER BY us_id DESC LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
|
---|
| 30 | }
|
---|
[328] | 31 |
|
---|
[375] | 32 | function get_total_users($data)
|
---|
| 33 | {
|
---|
| 34 | $sql="SELECT COUNT(".$this->id_name.") AS total FROM ".$this->table_name;
|
---|
| 35 | if (isset($data['keyword']))
|
---|
| 36 | {
|
---|
| 37 | $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced 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.