Commit 45079a1e authored by jwage's avatar jwage

[2.0] Refactoring ClassExporter to allow the getting of the generated sql as well as executing it

parent 438d970f
Upgrade to Doctrine 2.0
#######################
More information coming soon...
......@@ -58,12 +58,27 @@ class ClassExporter
}
/**
* Exports entity classes to a database, according to the specified mappings.
* Exports an array of class meta data instances to your database
*
* @param array $classes
*/
public function exportClasses(array $classes)
{
$exportClassesSql = $this->getExportClassesSql($classes);
foreach ($exportClassesSql as $sql) {
$this->_em->getConnection()->execute($sql);
}
}
/**
* Get an array of sql statements for the specified array of class meta data instances
*
* @param array $classes
* @return array $sql
*/
public function getExportClassesSql(array $classes)
{
$sql = array();
$foreignKeyConstraints = array();
// First we create the tables
......@@ -143,18 +158,20 @@ class ClassExporter
}
$foreignKeyConstraints[] = $constraint2;
$this->_sm->createTable($joinTable['name'], $joinTableColumns, array());
$sql = array_merge($sql, $this->_platform->getCreateTableSql($joinTable['name'], $joinTableColumns, array()));
}
}
$this->_sm->createTable($class->getTableName(), $columns, $options);
$sql = array_merge($sql, $this->_platform->getCreateTableSql($class->getTableName(), $columns, $options));
}
// Now create the foreign key constraints
if ($this->_platform->supportsForeignKeyConstraints()) {
foreach ($foreignKeyConstraints as $fkConstraint) {
$this->_sm->createForeignKey($fkConstraint['tableName'], $fkConstraint);
$sql = array_merge($sql, $this->_platform->getCreateForeignKeySql($fkConstraint['tableName'], $fkConstraint));
}
}
return $sql;
}
}
}
\ No newline at end of file
......@@ -32,10 +32,11 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\EntityManagerTest');
$suite->addTestSuite('Doctrine\Tests\ORM\EntityPersisterTest');
$suite->addTestSuite('Doctrine\Tests\ORM\CommitOrderCalculatorTest');
$suite->addTest(Query\AllTests::suite());
$suite->addTest(Hydration\AllTests::suite());
$suite->addTest(Entity\AllTests::suite());
$suite->addTest(Export\AllTests::suite());
$suite->addTest(Associations\AllTests::suite());
$suite->addTest(Mapping\AllTests::suite());
$suite->addTest(Functional\AllTests::suite());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment