예제 #1
0
 public function testForDuplicateIndexName2()
 {
     $schema = new ezcDbSchema(array('table1' => new ezcDbSchemaTable(array('field1' => new ezcDbSchemaField('integer')), array('index1' => new ezcDbSchemaIndex(array('field1' => new ezcDbSchemaIndexField())))), 'table2' => new ezcDbSchemaTable(array('field1' => new ezcDbSchemaField('integer')), array('index2' => new ezcDbSchemaIndex(array('field1' => new ezcDbSchemaIndexField())))), 'table3' => new ezcDbSchemaTable(array('field1' => new ezcDbSchemaField('integer')), array('index1' => new ezcDbSchemaIndex(array('field1' => new ezcDbSchemaIndexField())))), 'table4' => new ezcDbSchemaTable(array('field1' => new ezcDbSchemaField('integer')), array('index1' => new ezcDbSchemaIndex(array('field1' => new ezcDbSchemaIndexField()))))));
     $expected = array("The index name 'index1' is not unique. It exists for the tables: 'table1', 'table3', 'table4'.");
     self::assertEquals($expected, ezcDbSchemaValidator::validate($schema));
 }
예제 #2
0
<?php

/**
 * @package JetFuelCore
 */
require_once 'core/common.php';
$output = new ezcConsoleOutput();
$output->formats->info->color = 'blue';
// create a database schema from a database connection:
$db = ezcDbFactory::create(DB_DSN);
$dbSchema = ezcDbSchema::createFromDb($db);
// save a database schema to an XML file:
$dbSchema->writeToFile('xml', 'saved-schema.xml');
$messages = ezcDbSchemaValidator::validate($dbSchema);
foreach ($messages as $message) {
    $output->outputLine($message, 'info');
}
$readerClass = ezcDbSchemaHandlerManager::getReaderByFormat('xml');
$reader = new $readerClass();
$schema = ezcDbSchema::createFromFile('xml', 'saved-schema.xml');
$writer = new ezcDbSchemaPersistentWriter(true, null);
$writer->saveToFile('app/model/definitions', $schema);
$output->outputLine("Class files successfully written to app/model/definitions.", 'info');