【发布时间】:2013-03-28 04:16:02
【问题描述】:
我需要使用 postgresql 在数据库中生成所有实体关系。我可以使用下面的脚本生成它们。然而,并不是所有的表都会生成,只有那些有 SEQUENCES 的表才会生成。你知道告诉我如何正确生成所有表,而不仅仅是那些具有有限 SEQUENCES 的表吗?
[php]
[...]
$em->getConfiguration()->setMetadataDriverImpl(
new \Doctrine\ORM\Mapping\Driver\DatabaseDriver(
$em->getConnection()->getSchemaManager()
)
);
$cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
$metadata = $cmf->getAllMetadata();
$cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
$entityGenerator = new \Doctrine\ORM\Tools\EntityGenerator();
$entityGenerator->setAnnotationPrefix("");
$exporter = $cme->getExporter('annotation', __DIR__ . '/entities');
$exporter->setEntityGenerator($entityGenerator);
$exporter->setMetadata($metadata);
$etg = new \Doctrine\ORM\Tools\EntityGenerator;
$exporter->setEntityGenerator($etg);
$exporter->export();
【问题讨论】:
标签: php postgresql doctrine-orm annotations