function testDatabaseCanConnect() { $c = new Dase_Config(BASE_PATH); $c->load('inc/config.php'); $c->load('inc/local_config.php'); $db = new Dase_DB($c); $this->assertTrue($dbh = $db->getDbh()); }
public function getSchemaXml() { $writer = new XMLWriter(); $writer->openMemory(); $writer->setIndent(true); $writer->startDocument('1.0', 'UTF-8', 'yes'); $writer->startElement('database'); $writer->writeAttribute('name', Dase_DB::getDbName()); foreach ($this->listTables() as $table) { $writer->startElement('table'); $writer->writeAttribute('name', $table); foreach ($this->getMetadata($table) as $col) { $writer->startElement('column'); $writer->writeAttribute('name', $col['column_name']); $writer->writeAttribute('type', $col['data_type']); $writer->writeAttribute('null', $col['is_nullable']); if (false === strpos($col['column_default'], 'nextval')) { $writer->writeAttribute('default', $col['column_default']); } if ('id' == $col['column_name']) { $writer->writeAttribute('is_primary_key', 'true'); } if ($col['character_maximum_length']) { $writer->writeAttribute('max_length', $col['character_maximum_length']); } $writer->endElement(); } $writer->endElement(); } $writer->endElement(); $writer->endDocument(); return $writer->flush(true); }