0

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 using command line tools plz? I am using codeigniter framework(2.0), so solution based on that will be much appreciated.

Regards

Rana
  • 5,912
  • 12
  • 58
  • 91

1 Answers1

0

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

koosa
  • 2,966
  • 3
  • 31
  • 46