<?php

namespace App\Libraries\DBMigration\Process;

use CodeIgniter\Database\BaseConnection;

class ServerCodeProcess implements MigrationProcessInterface
{
  private $db;
  public function __construct(BaseConnection $db)
  {
    $this->db = $db;
  }
  public function process(array $row, int $cnt): void
  {
    $temps = [];
    $temps['code'] = trim($row['server_code']);
    $temps['status'] = 'default';
    if (!$this->db->table('codeinfo')->insert($temps)) {
      throw new \Exception($this->db->error()['message']);
    }
    echo "{$cnt} -> {$temps['code']} SERVERCODE 완료.\n";
  }
}
