32 lines
873 B
PHP
32 lines
873 B
PHP
<?php
|
|
|
|
namespace App\Libraries\DBMigration\Process;
|
|
|
|
use App\Entities\Equipment\PartEntity;
|
|
use CodeIgniter\Database\BaseConnection;
|
|
|
|
class PartCodeProcess implements MigrationProcessInterface
|
|
{
|
|
private $db;
|
|
public function __construct(BaseConnection $db)
|
|
{
|
|
$this->db = $db;
|
|
}
|
|
public function process(array $row, int $cnt): void
|
|
{
|
|
if (count($row) < 2) {
|
|
echo "{$cnt} {$row[0]}:{$row[1]}-> SKIP PARTCODE\n";
|
|
return;
|
|
}
|
|
$temps = [];
|
|
$temps['type'] = trim($row[0]);
|
|
$temps['title'] = trim($row[1]);
|
|
$temps['price'] = trim($row[2]);
|
|
$temps['status'] = PartEntity::DEFAULT_STATUS; // Assuming SwitchEntity has a STATUS_DEFAULT constant
|
|
if (!$this->db->table('partinfo')->insert($temps)) {
|
|
throw new \Exception($this->db->error()['message']);
|
|
}
|
|
echo "{$cnt} -> {$temps['title']} PARTCODE 완료.\n";
|
|
}
|
|
}
|