private function get_data() { $this->ci->db->join('rm r', 'r.mid = m.mid'); $this->ci->db->join('url u', 'u.rid = r.rid'); $query = $this->ci->db->get_where('mn m', ['u.uid' => $this->id, 'm.mstat' => TRUE]); $result = $query->result_array(); if (!empty($result)) { $data = []; $tmp = []; foreach ($result as $val) { $mpar = $val['mpar'] == 1 ? 0 : $val['mpar']; $tmp[$val['mid']][] = json_decode_db($val['rmk']); $data[$val['mid']] = ['mid' => $val['mid'], 'mpar' => $mpar, 'mnme' => $val['mnme'], 'mico' => $val['mico'], 'mlnk' => $val['mlnk']]; } $array_key = []; foreach ($tmp as $k => $v) { $array_key[$k] = []; foreach ($v as $vv) { if (is_array($vv) == FALSE) { continue; } $array_key[$k] = array_merge($array_key[$k], $vv); } $array_key[$k] = array_unique($array_key[$k]); sort($array_key[$k]); } foreach ($data as $kk => $vvv) { $data[$kk]['key'] = $array_key[$kk]; } } return isset($data) ? $data : []; }
public function init($rid = NULL) { $query = $this->db->select('mid, rmk')->get_where($this->_tbl, ['rid' => $rid]); $tmp = []; if ($query->num_rows() > 0) { $this->rid = $rid; foreach ($query->result_array() as $row) { $tmp[$row['mid']] = json_decode_db($row['rmk']); } return $tmp; } }