CI =& get_instance(); } public function run(callable $callback) { $this->CI->db->trans_begin(); try { $result = $callback(); if ($this->CI->db->trans_status() === false) { throw new RuntimeException('Operasi database gagal.'); } $this->CI->db->trans_commit(); return $result; } catch (Throwable $exception) { $this->CI->db->trans_rollback(); throw $exception; } } }