public static function createOrGetDBCWorker() { if (!isset(self::$dbcWorker)) { self::$dbcWorker = new DBC('./dep/dbcs/Spell.dbc', DBCMap::fromINI('./dep/maps/Spell.ini')); } return self::$dbcWorker; }
* * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License version 3 license (the "GPLv3"), in which * case the provisions of the GPLv3 are applicable instead of the above. * * @author Tim Kurvers <*****@*****.**> */ error_reporting(E_ALL | E_STRICT); require '../lib/bootstrap.php'; /** * This example shows how to create a DBC-file from scratch using DBC mappings */ // File we'll be using in this example $file = './dbcs/Sample.dbc'; // Load map from given INI-file (ensure read-access) $map = DBCMap::fromINI('./maps/Sample.ini'); // Attempt to create a new DBC at given path (ensure write-access) with given map $dbc = DBC::create($file, $map); // Adding a single record $dbc->add(1, 'John', 100, 1.8, 2, 0); // Adding multiple records in one call $dbc->add(array(2, 'Tim', 1337, 1.8, 1, 0), array(3, 'Pete', -10, 1.55, 1, 2)); // Failing to match the defined fields in the map (six, in this example) will silently and gracefully continue // The following will leave 100, 200, 0, 'Hello' out of the actual record $dbc->add(11, 'I am providing too many fields', 123, 1.2, 0, 0, 100, 200, 0, 'Hello'); // The following will append 0, 0, 0, 0 to the actual record $dbc->add(12, 'I am providing too little fields'); // Setting up a collection of records $records = array(); $records[] = array(4, 'Helen', 100, 1.8, 0, 0); $records[] = array(8, 'Frank', 1337, 1.73, 0, 0);
* The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License version 3 license (the "GPLv3"), in which * case the provisions of the GPLv3 are applicable instead of the above. * * @author Tim Kurvers <*****@*****.**> */ error_reporting(E_ALL | E_STRICT); require '../lib/bootstrap.php'; /** * This example shows how to export a DBC-file to JSON format */ // Open given DBC and given map (ensure read-access on both) $dbc = new DBC('./dbcs/Sample.dbc', DBCMap::fromINI('./maps/Sample.ini')); // When exporting to the standard PHP output, ensure the browser expects a JSON-document header('Content-Type: application/json'); // Set up a new JSON exporter $json = new DBCJSONExporter(); // And instruct it to export the given DBC (ensure the DBC has an attached map) $json->export($dbc); // Alternatively supports exporting to a file by providing a second argument $json->export($dbc, './export/sample.json');
* License for the specific language governing rights and limitations * under the License. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License version 3 license (the "GPLv3"), in which * case the provisions of the GPLv3 are applicable instead of the above. * * @author Tim Kurvers <*****@*****.**> */ error_reporting(E_ALL | E_STRICT); require '../lib/bootstrap.php'; /** * This example shows how to manually construct a DBC mapping through the API */ // Construct a new (empty) DBC mapping $map = new DBCMap(); // Add 'id' field (defaults to unsigned integer) $map->add('id'); // Add 'name' as a string field (Use DBC::STRING_LOC for a localized string) $map->add('name', DBC::STRING_LOC); // Add 'points' as a signed integer field $map->add('points', DBC::INT); // Add 'height' as a float field $map->add('height', DBC::FLOAT); // Add 'friend1' and 'friend2' as signed integer fields $map->add('friend', DBC::INT, 2); // Add a random field $map->add('remove-me'); // And remove it again $map->remove('remove-me'); var_dump($map);
/** * Attaches a mapping */ public function attach(DBCMap $map = null) { $this->_map = null; if ($map !== null) { $delta = $map->getFieldCount() - $this->getFieldCount(); if ($delta !== 0) { throw new DBCException('Mapping holds ' . $map->getFieldCount() . ' fields, but DBC "' . $this->_path . '" expects ' . $this->getfieldCount()); return $this; } $this->_map = clone $map; } return $this; }
* * This library allows creation, reading and export of World of Warcraft's * client-side database files. These so-called DBCs store information * required by the client to operate successfully and can be extracted * from the MPQ archives of the actual game client. * * The contents of this file are subject to the MIT License, under which * this library is licensed. See the LICENSE file for the full license. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * @author Tim Kurvers <*****@*****.**> */ error_reporting(E_ALL | E_STRICT); require '../lib/bootstrap.php'; /** * This example shows how to generate a DBC mapping by sampling a given DBC */ // Open the given DBC (ensure read-access) $dbc = new DBC('./dbcs/Sample.dbc'); // Construct a map by predicting the fields in the given DBC $map = DBCMap::fromDBC($dbc); // Dump the first record using the mappings $dbc->getRecord(0)->dump(true); var_dump($map);
* The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License version 3 license (the "GPLv3"), in which * case the provisions of the GPLv3 are applicable instead of the above. * * @author Tim Kurvers <*****@*****.**> */ error_reporting(E_ALL | E_STRICT); require '../lib/bootstrap.php'; /** * This example shows how to export a DBC-file to SQL format for use with databases */ // Open given DBC and given map (ensure read-access on both) $dbc = new DBC('./dbcs/Spell.dbc', DBCMap::fromINI('./maps/Spell.ini')); // Set up a new database exporter $dbe = new DBCDatabaseExporter(); // And instruct it to export the given DBC to the default table 'dbc' (ensure the DBC has an attached map) $dbe->export($dbc); // Alternatively supports exporting to a file by providing a second argument $dbe->export($dbc, './export/spell.sql'); // If you would rather export to a specific table, pass in a third parameter //$dbe->export($dbc, './export/sample.sql', 'my_table');