public function generateTableXml($tables, $constraints, $storage) { $xml = array(); foreach ($tables as $table) { // Calculate classname $className = ucfirst($table->name); if (isset($this->prefix)) { switch (1) { case FALSE == $this->ptargets: case in_array($table->name, $this->ptargets) && FALSE == $this->pexclude: case !in_array($table->name, $this->ptargets) && TRUE == $this->pexclude: $className = $this->prefix . $className; break; } } $gen = DBXmlGenerator::createFromTable($table, $this->host, $this->adapter->conn->dsn->getDatabase())->getTree(); // Add extra information with($node = $gen->root->children[0]); $node->setAttribute('dbtype', $this->adapter->conn->dsn->getDriver()); $node->setAttribute('class', $className); $node->setAttribute('package', $this->package); $xml[] = $storage->write($className, $gen->getSource(INDENT_DEFAULT)); } $storage->write(self::CONSTRAINT_FILE_NAME, $constraints->getSource(INDENT_DEFAULT)); return $xml; }
/** * Sets up a Database Object for the test * */ public function setUp() { $generated = DBXmlGenerator::createFromTable($this->newTable('deviceinfo', array('deviceinfo_id' => array(DB_ATTRTYPE_INT, 255), 'serial_number' => array(DB_ATTRTYPE_INT, 16), 'text' => array(DB_ATTRTYPE_TEXT, 255))), 'localhost', 'FOOBAR'); $this->xpath = new XPath($generated->getSource()); }