2016-09-01 10:15:17 +00:00
|
|
|
<?php
|
|
|
|
chdir(__DIR__);
|
|
|
|
|
|
|
|
require_once __DIR__ . "/../bootstrap.php";
|
|
|
|
|
|
|
|
|
|
|
|
// Show table creation statements
|
|
|
|
// And (re)generate Proxies
|
|
|
|
|
2016-09-01 10:25:51 +00:00
|
|
|
$em = EmotionHero\Application::getInstance()->getEm();
|
2016-09-01 10:15:17 +00:00
|
|
|
|
|
|
|
var_dump($em->getConnection()->getDatabasePlatform()->getName());
|
|
|
|
// $serializer = JMS\Serializer\SerializerBuilder::create()->build();
|
|
|
|
|
|
|
|
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
|
|
|
// $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
|
|
|
|
$destPath = $em->getConfiguration()->getProxyDir();
|
|
|
|
$em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
|
|
|
|
|
|
|
|
|
|
|
|
$tool = new Doctrine\ORM\Tools\SchemaTool($em);
|
|
|
|
|
|
|
|
$classes = $metadatas;
|
|
|
|
|
|
|
|
|
|
|
|
// $classes = array(
|
|
|
|
// $em->getClassMetadata('EmotionHero\Models\Emotion'),
|
|
|
|
// );
|
|
|
|
|
|
|
|
// $tool->getCreateDatabaseSQL();
|
|
|
|
$queries = $tool->getCreateSchemaSQL($classes);
|
|
|
|
// $queries = $tool->getUpdateSchemaSql($classes);
|
|
|
|
foreach($queries as $sql){ echo "$sql;\n"; }
|
|
|
|
// updateSchema
|
|
|
|
$tool->updateSchema($classes);
|
|
|
|
|
|
|
|
|
|
|
|
$emotions = ['anger','contempt','disgust', 'fear', 'joy','sadness','surprise'];
|
|
|
|
foreach($emotions as $emo) {
|
|
|
|
$emotion = new EmotionHero\Models\Emotion();
|
|
|
|
$emotion->setName($emo);
|
|
|
|
$em->persist($emotion);
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = new EmotionHero\Models\User();
|
|
|
|
$em->persist($user);
|
|
|
|
|
|
|
|
$em->flush();
|
|
|
|
|
|
|
|
var_dump($user->getId());
|