} // Store the dump. $dumpFile = NN_RES . $match[2] . '_predb_dump.csv'; $fetched = file_put_contents($dumpFile, $dump); if (!$fetched) { echo 'Error storing dump file ' . $match[2] . ' in (' . NN_RES . ').' . PHP_EOL; continue; } // Make sure it's readable by all. chmod($dumpFile, 0777); $local = strtolower($argv[2]) == 'local' ? true : false; $verbose = $argv[3] == true ? true : false; importDump($dumpFile, $local, $verbose); // Delete the dump. // unlink($dumpFile); $progress = rw_progress(settings_array($match[2] + 1, $progress), false); echo 'Successfully imported PreDB dump ' . $match[2] . ' ' . --$total . ' dumps remaining to import.' . PHP_EOL; } } // Drop tmp_pre table $pdo->queryExec('DROP TABLE IF EXISTS tmp_pre'); } function settings_array($last = null, $settings = null) { if (is_null($settings)) { $settings['last'] = 0; } if (!is_null($last)) { $settings['last'] = $last; } return $settings;
// Import file into predb_imports $predb->executeLoadData(['fields' => '\\t\\t', 'lines' => '\\r\\n', 'local' => $local, 'path' => $dumpFile]); // Remove any titles where length <=8 if ($verbose === true) { echo $predb->log->info("Deleting any records where title <=8 from Temporary Table"); } $predb->executeDeleteShort(); // Add any groups that do not currently exist $predb->executeAddGroups(); // Fill the group_id $predb->executeUpdateGroupID(); echo $predb->log->info("Inserting records from temporary table into predb table"); $predb->executeInsert(); // Delete the dump. unlink($dumpFile); $progress = $predb->progress(settings_array($match[2] + 1, $progress), ['read' => false]); echo "Successfully imported PreDB dump {$match[2]}, " . --$total . ' dumps remaining.' . PHP_EOL; } else { echo "Ignoring: {$file['download_url']}\n"; } } else { if (nZEDb_DEBUG) { echo "^https://raw.githubusercontent.com/nZEDb/nZEDbPre_Dumps/master/dumps/{$filePattern}\$\n {$file['download_url']}\n"; } } } function settings_array($last = null, $settings = null) { if (is_null($settings)) { $settings['last'] = 0; }