_targetDB === null) { $this->_targetDB = \Config\Database::connect('default'); } return $this->_targetDB; } /** * 공통 마이그레이션 처리 로직 */ final protected function execute(MigrationProcessInterface $processor, array $rows, string $functionName, string $site): void { $this->getTargetDB()->transStart(); $total = count($rows); $cnt = 1; try { foreach ($rows as $row) { $processor->process($site, $row, $cnt); echo "{$site} => {$cnt} 번째/{$total} => {$functionName} 작업을 완료하였습니다."; $cnt++; } $this->getTargetDB()->transCommit(); } catch (\Exception $e) { $this->getTargetDB()->transRollback(); echo "{$site} => {$cnt} 번째/{$total} {$functionName} 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n"; } } }