How can I re-create my database with PHP, perhaps by inserting default data. Currently, I intend to use the behavior for Unit Tests.
I use Doctrine 2, Zend Framework 1.11, Zend_Test for unit tests
I could use the CLI
doctrine orm:schema-tool:update --force
Or
doctrine orm:schema-tool:drop --force doctrine orm:schema-tool:create
I'm looking for a replacement for PHP so far found this
but it will look something like
$tool = new \Doctrine\ORM\Tools\SchemaTool($em); $classes = array( $em->getClassMetadata('Entities\User'), $em->getClassMetadata('Entities\Profile') ); $tool->dropSchema($classes, \Doctrine\ORM\Tools\SchemaTool::DROP_DATABASE); $tool->createSchema($classes);
And I really do not want to specify model classes, esp in development, when they can change. It should just read from all the classes listed in ... below ... just like with the CLI, do you need to specify the classes you need?
$driverImpl = $config->newDefaultAnnotationDriver(array(realpath('../models'))); $config->setMetadataDriverImpl($driverImpl);
Jiew meng
source share