source: pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php @ 371

Last change on this file since 371 was 371, checked in by quyenla, 11 years ago

collaborator order sourcecode

File size: 1.9 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class 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            $order="";
23            if ($data['sorting_order'] != "sorting")
24            {
25                if ($data['sorting_field'] != "money")
26                {
27                $sort="DESC";
28                if ($data['sorting_order']=="sorting_asc") $sort = "ASC";
29                $order="ORDER BY ".$data['sorting_field']." ".$sort;
30                }
31            }
32           
33            return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
34
35        }
36        function isExist($data)
37        {
38            $sql="SELECT COUNT(id) as total FROM ".$this->table_name." WHERE ".$data['field']." = '".$data['value']."' LIMIT 1";
39            if ($this->db->query($sql)->row_array()['total']==1)
40            {
41                return true;
42            }
43            else
44            {
45                return false;
46            }
47           
48        }
49        function countCollaborator($data)
50        {
51            $sql="SELECT COUNT(id) as total FROM ".$this->table_name;
52            if (isset($data['keyword']))
53            {
54            $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";
55            }
56
57            return $this->db->query($sql)->row_array()['total'];
58           
59        }
60}
Note: See TracBrowser for help on using the repository browser.