_sourceDB === null) { $config = [ 'DSN' => '', 'hostname' => env('database.source.hostname', 'localhost'), 'username' => env('database.source.username', 'root'), 'password' => env('database.source.password', ''), 'database' => env('database.source.database', 'primeidc'), 'DBDriver' => 'MySQLi', 'DBPrefix' => '', 'pConnect' => false, 'DBDebug' => (ENVIRONMENT !== 'production'), 'cacheOn' => false, 'cacheDir' => '', 'charset' => 'utf8mb4', 'DBCollat' => 'utf8mb4_general_ci', 'swapPre' => '', 'encrypt' => false, 'compress' => false, 'strictOn' => false, 'failover' => [], 'port' => 3306, ]; $this->_sourceDB = \Config\Database::connect($config); } return $this->_sourceDB; } /** * 공통 쿼리 실행 메서드 */ private function executeQuery(string $sql, array $params = []): array { return $this->getSourceDB() ->query($sql, $params) ->getResultArray(); } private function executeFile(string $filename, string $deilmeter = ','): array { $datas = []; $lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { $datas[] = explode($deilmeter, $line); } return $datas; } protected function getClient(): array { return $this->executeQuery(self::SQL_GET_CLIENT); } protected function getLine(): array { return $this->executeQuery(self::SQL_GET_LINE); } protected function getServerCode(): array { return $this->executeQuery(self::SQL_GET_SERVER_CODE, ['%일회성%']); } protected function getSwitchCode(): array { return $this->executeQuery(self::SQL_GET_SWITCH_CODE, ['%일회성%']); } protected function getPartCode(): array { return $this->executeFile('/home/donfig/dbmsv2/app/Database/dbmsv2_part.txt'); } final public function client(): void { $this->migration( new ClientProcess($this->getTargetDB()), $this->getClient(), __FUNCTION__ ); } final public function line(): void { $this->migration( new LineProcess($this->getTargetDB()), $this->getLine(), __FUNCTION__ ); } final public function servercode(): void { $this->migration( new ServerCodeProcess($this->getTargetDB()), $this->getServerCode(), __FUNCTION__ ); } final public function switchcode(): void { $this->migration( new SwitchCodeProcess($this->getTargetDB()), $this->getSwitchCode(), __FUNCTION__ ); } final public function partcode(): void { $this->migration( new PartCodeProcess($this->getTargetDB()), $this->getPartCode(), __FUNCTION__ ); } }