load->database(); } function name_list(){ $this->db->order_by('id', 'DESC'); $query = $this->db->get('master_device_access'); return $query->result(); } function save_name($post) { $slot_name = $post['slot_name']; $data = array( 'name' => $slot_name, ); $this->db->insert('master_device_access', $data); } function delete_name($id) { $this->db->where('id', $id); $this->db->delete('master_device_access'); } function edit_name($post,$id){ $data = array( 'name' => $post['slotEditname'], ); $this->db->where('id', $id); $this->db->update('master_device_access', $data); } function duplicate_entry($post) { $val = $post['val']; if (isset($post['currId'])) { $currId = $post['currId']; $query1 = $this->db->get_where('master_device_access', array('id' => $currId)); $exceptVal = $query1->result()[0]->name; // SELECT * FROM `master_device_access` WHERE name='12Hours' AND name!='vatibra' $this->db->where('name', $val); $this->db->where('name !=', $exceptVal); $query = $this->db->get('master_device_access'); } else{ $query = $this->db->get_where('master_device_access', array('name' => $val)); } if($query->num_rows() > 0) { return 'exist'; } else{ return 'notexist'; } } function status_change($post){ $id = $post['id']; $stat = $post['val']; $this->db->set('status', $stat); $this->db->where('id', $id); $this->db->update('master_device_access'); if($stat == '1') { return 'Status set active'; } else{ return 'Status set deactive'; } } function getWherevalue($id){ $this->db->where('id', $id); $query = $this->db->get('master_device_access'); return $query->result(); } function getNameBysearch($search,$orderColumn, $orderType) { if($orderColumn==0) $this->db->order_by('id', $orderType); else if($orderColumn==1) $this->db->order_by('name', $orderType); else if($orderColumn==2) $this->db->order_by('status', $orderType); $this->db->like('id', $search); $this->db->or_like('name', $search); $this->db->or_like('status', $search); $query = $this->db->get('master_device_access'); return $query->result(); } function getNameByLimit($limit, $start, $orderColumn, $orderType) { if($orderColumn==0) $this->db->order_by('id', $orderType); else if($orderColumn==1) $this->db->order_by('name', $orderType); else if($orderColumn==2) $this->db->order_by('status', $orderType); $this->db->limit($limit, $start); $query = $this->db->get('master_device_access'); return $query->result(); } function getNameByLimitBySearch($limit, $start, $search) { $this->db->like('id', $search); $this->db->order_by('id', 'desc'); $this->db->or_like('name', $search); $this->db->or_like('status', $search); $this->db->limit($limit, $start); $query = $this->db->get('master_device_access'); return $query->result(); } }