load->database(); } public function get($id = null) { header('Content-Type: application/json'); try { if ($id === null || !is_numeric($id)) { throw new Exception('Invalid or missing ID parameter.'); } $query = $this->db ->select('mergeRequestPayload') ->where('mergeRequestID', $id) ->get('merge_request'); if ($query->num_rows() === 0) { throw new Exception('Record not found.'); } $row = $query->row(); $payload = json_decode($row->mergeRequestPayload, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new Exception('Invalid JSON in mergeRequestPayload.'); } echo json_encode([ 'status' => 'OK', 'data' => $payload ]); } catch (Exception $e) { echo json_encode([ 'status' => 'ERR', 'message' => $e->getMessage() ]); } } }