db->select('id, name'); $this->db->order_by("convert(name using gbk)","ASC"); if (isset($filter['keyword'])) { if (!empty($filter['keyword'])) { $this->db->like('name',$filter['keyword']); } } unset($filter['keyword']); foreach ($filter as $key => $value) { if (is_array($value)) { if (!empty($value)) { $this->db->where_in($key,$value); }else{ $this->db->where_in($key,array(0)); } }else{ $this->db->where($key,$value); } } // $this->db->order_by('name','ASC'); $query = $this->db->get($this->table); return $query->result_array(); } public function get_zone_by_filter($filter,$role=null,$companyid=null){ if ($role == SYSTEM_ADMIN) { if (isset($filter['id'])) { unset($filter['id']); } } else { $filter['id'] = $companyid; } foreach ($filter as $k => $v){ if (is_array($v)) { if (!empty($v)) { $this->db->where_in($k,$v); }else{ $this->db->where_in($k,array(0)); } }else{ $this->db->where($k,$v); } } $this->db->order_by("name","ASC"); $query = $this->db->get($this->table); return $query->result_array(); } public function get_data_by_id($id, $field = '*',$keyword = ''){ $this->db->where('id',$id); if (!empty($keyword)) { $this->db->like('name',$keyword); } $query = $this->db->get($this->table); $row = $query->row_array(); if ($field == '*') { return $row; } else { return !empty($row) ? $row[$field] : ''; } } public function getDataCount($condition, $id = 0) { if (!empty($condition)){ foreach ($condition as $k => $v) { $this->db->where($k,$v); } } if (!empty($id)) { $this->db->where('id !=',$id); } $query = $this->db->get($this->table); $company = $query->row_array(); if (empty($company)) { return 0; } else { return $id == $company['id'] ? 0 : 1; } } }