PHPackages                             erorus/db2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. erorus/db2

ActiveLibrary[Database &amp; ORM](/categories/database)

erorus/db2
==========

DB2 Reader for World of Warcraft data files

318.5k↓84.6%15[1 issues](https://github.com/erorus/db2/issues)PHP

Since Apr 6Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/erorus/db2)[ Packagist](https://packagist.org/packages/erorus/db2)[ RSS](/packages/erorus-db2/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/daa4b47652229a4755b6dc9e48e3dc803051525005a83851290ba883cb322294/68747470733a2f2f7472617669732d63692e6f72672f65726f7275732f6462322e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/erorus/db2) [![Coverage Status](https://camo.githubusercontent.com/a304de97d819d107fe12865d677f24b647ce19fdeda9dee6c80b1172130a7601/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f65726f7275732f6462322f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/erorus/db2?branch=master) [![Become a Patron!](https://camo.githubusercontent.com/265592242ebdb66ea971dc7343aff2bcce69fed0fc5ef3ffcbfb9dfdac8008f8/68747470733a2f2f65766572796e6f7468696e672e6e65742f706174726f6e427574746f6e2e706e67)](https://www.patreon.com/bePatron?u=4445407)

DB2 Reader
==========

[](#db2-reader)

This is a small library to read DB2 and ADB/DBCache files (data tables) from World of Warcraft.

Requirements
------------

[](#requirements)

This was developed using 64-bit PHP 7. Tests are also run against PHP 5.6. 64-bit versions are recommended to support unsigned 32-bit ints and 64-bit ints.

Mbstring extension is required for all formats, and gmp extension is required for WDC1 support.

Usage
-----

[](#usage)

```
// Instantiate an object with the path to a DB2 file.
$db2Reader = new Reader("Achievement.db2");

// Records are presented as simple arrays.
// Some fields are, themselves, arrays of values.
// Get individual records by ID with:
$record = $db2Reader->getRecord(17);

// Loop through records with:
foreach ($db2Reader->generateRecords() as $id => $record) { ... }

// All valid record IDs:
$ids = $db2Reader->getIds();

// You can set field names for convenience:
$db2Reader->setFieldNames([0 => "name", 1 => "note", ...]);
$record = $db2Reader->getRecord(17);
if ($record['name'] == "...") ...

// All integers are assumed to be unsigned, but you can change that by field:
$db2Reader->setFieldsSigned([2 => true, 7 => true]);
$record = $db2Reader->getRecord(17);
if ($record[2] < 0) ...

// You can get the calculated field types,
// useful when dynamically creating database tables:
$types = $db2Reader->getFieldTypes();
if ($types['name'] == Reader::FIELD_TYPE_STRING) ...

// You can load an ADB or DBCache, as long as you have its parent DB2.
// That reader will only expose records in the Hotfix/DBCache file.
$adbReader = $db2Reader->loadAdb("Achievement.adb");
$dbCacheReader = $db2Reader->loadDBCache("DBCache.bin");

// Finally, you can specify both the DB2 and the DBCache file when constructing a HotfixedReader.
// This has the same interface as Reader, but will substitute hotfixed records when available.
$hotReader = new HotfixedReader("Achievement.db2", "DBCache.bin");
```

Also check out example.php, which is what I'm using during development.

Compatibility
-------------

[](#compatibility)

VersionFormatWorksUnit Tests3.x - 6.xWDB2✓✓7.0.1WDB37.0.3WDB47.0.3 - 7.2.0WDB5✓✓7.0.3 - 7.2.0WCH7/8✓7.2.0 - 7.3.2WDB6✓✓7.2.0 - ?DBCache.bin✓7.3.5WDC1✓8.0.1WDC2✓1.13.21SLC✓8.1.0 - ?WDC3✓All features of DB2 files should be supported (offset map / embedded strings, copy blocks, common blocks, pallet data, etc).

Encrypted blocks are expected to be decrypted by your CASC tool before being read by this library. For blocks that cannot be decrypted (because the key is unknown, for example), your CASC tool should substitute NUL bytes for the length of the encrypted blocks. DB2Reader ignores blocks which are encrypted and are empty of data.

ADBs/DBCache require their counterpart DB2 file for necessary metadata, and Internet access to get field sizes via [WoWDBDefs](https://github.com/wowdev/WoWDBDefs).

Goals
-----

[](#goals)

This is used for The Undermine Journal ([Newsstand](https://github.com/erorus/newsstand/)) to datamine items, pets, and other entities.

Disclaimers
-----------

[](#disclaimers)

This work is neither endorsed by nor affiliated with Blizzard Entertainment.

Thanks
------

[](#thanks)

Most of the file format details were found by documentation at [the WoWDev wiki](https://wowdev.wiki/DB2). Thanks to those who contribute there!

Thanks to [WoWDBDefs](https://github.com/wowdev/WoWDBDefs) for providing the table formats used by the game executable so we can parse hotfixes.

License
-------

[](#license)

Copyright 2017 Gerard Dombroski

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance55

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 99.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/59848fdf0747788942e0c30e483a8eccb4698e0c34db490db565b6a18992442d?d=identicon)[darki73](/maintainers/darki73)

---

Top Contributors

[![erorus](https://avatars.githubusercontent.com/u/4028574?v=4)](https://github.com/erorus "erorus (112 commits)")[![exochron](https://avatars.githubusercontent.com/u/1702741?v=4)](https://github.com/exochron "exochron (1 commits)")

---

Tags

db2db2-readerwdb6world-of-warcraft

### Embed Badge

![Health badge](/badges/erorus-db2/health.svg)

```
[![Health](https://phpackages.com/badges/erorus-db2/health.svg)](https://phpackages.com/packages/erorus-db2)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
