$begintime = time(); echo "Creating new collections, binaries, and parts tables for each active group...\n"; foreach ($actgroups as $group) { if ($groups->createNewTPGTables($group['id']) === false) { exit($pdo->log->error("There is a problem creating new parts/files tables for group {$group['name']}.")); } $consoletools->overWrite("Tables Created: " . $consoletools->percentString($gdone * 3, $newtables)); $gdone++; } $endtime = time(); echo "\nTable creation took " . $consoletools->convertTime($endtime - $begintime) . ".\n"; $starttime = time(); echo "\nNew tables created, moving data from old tables to new tables.\nThis will take awhile....\n\n"; while ($cdone < $clen['total']) { // Only load 1000 collections per loop to not overload memory. $collections = $pdo->queryAssoc('select * from collections limit ' . $cdone . ',1000;'); if ($collections instanceof \Traversable) { foreach ($collections as $collection) { $collection['subject'] = $pdo->escapeString($collection['subject']); $collection['fromname'] = $pdo->escapeString($collection['fromname']); $collection['date'] = $pdo->escapeString($collection['date']); $collection['collectionhash'] = $pdo->escapeString($collection['collectionhash']); $collection['dateadded'] = $pdo->escapeString($collection['dateadded']); $collection['xref'] = $pdo->escapeString($collection['xref']); $collection['releaseid'] = $pdo->escapeString($collection['releaseid']); $oldcid = array_shift($collection); if ($debug) { echo "\n\nCollection insert:\n"; print_r($collection); echo sprintf("\nINSERT INTO collections_%d (subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid) VALUES (%s)\n\n", $collection['group_id'], implode(', ', $collection)); }