function update_row() {
// Get the raw input from the request
$raw_input = $this->input->raw_input_stream;
log_message('info', 'Raw input: ' . $raw_input);
// Decode the JSON input
$data = json_decode($raw_input, true);
// Check for JSON decode errors
if (json_last_error() !== JSON_ERROR_NONE) {
log_message('error', 'JSON decode error: ' . json_last_error_msg());
echo json_encode(['status' => 'error', 'message' => 'Invalid JSON format']);
return;
}
// Ensure data is an array and contains the necessary fields
if (!is_array($data) || !isset($data['id'])) {
log_message('error', 'Decoded data is not an array or missing ID. Data: ' . print_r($data, true));
echo json_encode(['status' => 'error', 'message' => 'Missing ID']);
return;
}
// Log the data for debugging
log_message('info', 'Received data: ' . print_r($data, true));
// Process and update the data
$update_result = $this->Logistic_m->update_row($data);
if ($update_result) {
log_message('info', 'Row updated successfully');
echo json_encode(['status' => 'success']);
} else {
log_message('error', 'Database update error');
echo json_encode(['status' => 'error', 'message' => 'Database update error']);
}
}
I try to save the row, but the frontend is updated successfully, but database not updated