【问题标题】:Doctrine ORM 2 - Generate Entities from database without sequencesDoctrine ORM 2 - 从没有序列的数据库中生成实体
【发布时间】: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


    【解决方案1】:

    Doctrine 不仅生成具有表 SEQUENCES 的实体。事实上,Doctrine 的行为是不同的,因为生成了有无序列的实体。

    不一定每个表都是一个实体,因为一个实体可以有可能不代表一个新实体的关系。

    那么已经被使用的是如何工作的!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      • 2011-08-15
      • 2013-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多