$value) { if (is_array($value)) { if (!empty($value)) { $this->db->where_in($key,$value); } }else{ $this->db->where($key,$value); } } $data = $this->db->get($this->table)->result_array(); foreach ($data as $k=>$v) { if (empty($v['lampid'])) { $data[$k]['count'] = 0; }else{ $ids = explode(',', $v['lampid']); $data[$k]['count'] = count($ids); } } return $data; } public function get_count_by_filter($filter){ $this->db->select('count(*) as total'); foreach ($filter as $key => $value) { if (is_array($value)) { if (!empty($value)) { $this->db->where_in($key,$value); } }else{ $this->db->where($key,$value); } } $data = $this->db->get($this->table)->row_array(); return $data['total']; } public function getData($filter){ if (!empty($filter)) { foreach ($filter as $key => $value) { if (is_array($value)) { if (!empty($value)) { $this->db->where($key,$value); }else{ $this->db->where($key,array(0)); } }else{ $this->db->where($key,$value); } } }else{ return array(); } return $this->db->get($this->table)->row_array(); } 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); $data = $query->row_array(); if (empty($data)) { return 0; } else { return $id == $data['id'] ? 0 : 1; } } } ?>