示例#1
0
 // Store the dump.
 $dumpFile = nZEDb_RES . $match[2] . '_predb_dump.csv';
 $fetched = file_put_contents($dumpFile, $dump);
 if (!$fetched) {
     echo "Error storing dump file {$match[2]} in (" . nZEDb_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;
 if ($verbose) {
     echo $predb->log->info("Clearing import table");
 }
 // Truncate to clear any old data
 $predb->executeTruncate();
 // 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);