Line | |
---|
1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
2 |
|
---|
3 | class Collabolator_model extends MY_Model
|
---|
4 | {
|
---|
5 |
|
---|
6 | protected $table_name = 'tblcollaborator';
|
---|
7 | protected $id_name = 'id';
|
---|
8 |
|
---|
9 | function __construct()
|
---|
10 | {
|
---|
11 | parent::__construct();
|
---|
12 | }
|
---|
13 | function getCollaborator($data)
|
---|
14 | {
|
---|
15 | $sql="SELECT * FROM ".$this->table_name;
|
---|
16 | $data['keyword']='';
|
---|
17 |
|
---|
18 | if ($data['keyword'])
|
---|
19 | {
|
---|
20 | $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";
|
---|
21 | }
|
---|
22 | return $this->db->query($sql." ORDER BY id DESC LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
|
---|
23 |
|
---|
24 | }
|
---|
25 | function isExist($data)
|
---|
26 | {
|
---|
27 | $sql="SELECT COUNT(id) as total FROM ".$this->table_name." WHERE ".$data['field']." = '".$data['value']."' LIMIT 1";
|
---|
28 | if ($this->db->query($sql)->row_array()['total']==1)
|
---|
29 | {
|
---|
30 | return true;
|
---|
31 | }
|
---|
32 | else
|
---|
33 | {
|
---|
34 | return false;
|
---|
35 | }
|
---|
36 |
|
---|
37 | }
|
---|
38 | function countCollaborator($data)
|
---|
39 | {
|
---|
40 | $sql="SELECT COUNT(id) as total FROM ".$this->table_name;
|
---|
41 | if (isset($data['keyword']))
|
---|
42 | {
|
---|
43 | $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";
|
---|
44 | }
|
---|
45 |
|
---|
46 | return $this->db->query($sql)->row_array()['total'];
|
---|
47 |
|
---|
48 | }
|
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.