0

我想自动创建我所有的数据库表作为学说表模式。教义版本是2。谁能帮助我如何通过php本身而不是使用命令行工具来获取它?我正在使用 codeigniter 框架(2.0),因此基于此的解决方案将不胜感激。

问候

4

1 回答 1

0

您需要实例化 SchemaTool。此代码应该适合您:

$em = $this->doctrine->em;

$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
$tool->dropDatabase();
$classes = array(
  $em->getClassMetadata('user')
);
$tool->createSchema($classes);

http://www.doctrine-project.org/docs/orm/2.0/en/reference/tools.html

于 2011-07-29T15:17:26.403 回答