public function down() { $this->dropTable(LocationBlock::tableName()); }
public function applyBlockCsv($file) { $columns = ['id', 'start', 'end']; $update = ['id', 'start']; $rows = []; if (($handle = fopen($file, 'r')) !== false) { while (($data = fgetcsv($handle, 1000, ',')) !== false) { if (!isset($data[2]) || intval($data[2]) === 0) { continue; } $rows[] = [(int) $data[2], (int) $data[0], (int) $data[1]]; if (count($rows) === $this->maxExecuteRows) { $this->batchInsertDuplicate(LocationBlock::tableName(), $columns, $rows, $update)->execute(); $rows = []; } } if (count($rows) > 0) { $this->batchInsertDuplicate(LocationBlock::tableName(), $columns, $rows, $update)->execute(); } fclose($handle); } }