开发者

doctrine model schema from mysql tables

开发者 https://www.devze.com 2023-02-23 14:08 出处:网络
i want to create all my database tables as doctrine table schema automatically. doctrine version is 2. Can anyone please help me how to get this by php itself instead of usi开发者_StackOverflow社区ng

i want to create all my database tables as doctrine table schema automatically. doctrine version is 2. Can anyone please help me how to get this by php itself instead of usi开发者_StackOverflow社区ng command line tools plz? I am using codeigniter framework(2.0), so solution based on that will be much appreciated.

Regards


You need to instantiate SchemaTool. This code should work for you:

$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

0

精彩评论

暂无评论...
验证码 换一张
取 消