Files
BE_IBL/application/controllers/tools/Merge_report.php
2026-04-15 15:23:57 +07:00

48 lines
1.3 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Merge_report extends MY_Controller {
public function __construct() {
parent::__construct();
$this->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()
]);
}
}
}