function BuildItemDefs() { $itemDB2 = new Reader(__DIR__ . '/../DBC/current/enUS/Item.db2'); $ids = $itemDB2->getIds(); unset($itemDB2); $idMap = []; foreach ($ids as $id) { $idMap[$id] = $id; } DebugMessage("Item ID count: " . count($idMap)); $sparseDB2 = new Reader(__DIR__ . '/../DBC/current/enUS/Item-sparse.db2', [13, 14, 15, 16, 17]); $ids = $sparseDB2->getIds(); unset($sparseDB2); DebugMessage("Sparse ID count: " . count($ids)); foreach ($ids as $id) { unset($idMap[$id]); } DebugMessage("Missing ID count: " . count($idMap)); if (!count($idMap)) { return false; } $idMap = array_reverse($idMap); reset($idMap); $lastId = current($idMap); DebugMessage("Last item ID: {$lastId}"); $lua = "local addonName, addonTable = ...\n"; $lua .= "addonTable.missingItems = {" . implode(',', $idMap) . "}\n"; return $lua; }
$stmt->close(); EchoProgress(false); unset($reader); $stmt = $db->prepare("insert ignore into tblDBCItemRandomSuffix (locale, suffix) (select distinct '{$locale}', name_{$locale} from tblDBCRandEnchants where trim(name_{$locale}) != '' and id < 0)"); $stmt->execute(); $stmt->close(); LogLine("{$locale} tblDBCPet"); $battlePetReader = new Reader($dirnm . '/BattlePetSpecies.db2'); $battlePetReader->setFieldNames(['npc']); $creatureReader = new Reader($dirnm . '/Creature.db2'); $creatureReader->setFieldNames([4 => 'name']); $stmt = $db->prepare("insert into tblDBCPet (id, name_{$locale}) values (?, ?) on duplicate key update name_{$locale} = values(name_{$locale})"); $species = $name = null; $stmt->bind_param('is', $species, $name); $x = 0; $recordCount = count($battlePetReader->getIds()); foreach ($battlePetReader->generateRecords() as $id => $rec) { EchoProgress(++$x / $recordCount); $species = $id; $creature = $creatureReader->getRecord($rec['npc']); if (is_null($creature)) { continue; } $name = $creature['name']; $stmt->execute(); } $stmt->close(); EchoProgress(false); unset($creatureReader); unset($battlePetReader); /* */