50 lines
No EOL
1.3 KiB
PHP
50 lines
No EOL
1.3 KiB
PHP
<?php
|
|
chdir(__DIR__);
|
|
|
|
require_once __DIR__ . "/../bootstrap.php";
|
|
|
|
|
|
// Show table creation statements
|
|
// And (re)generate Proxies
|
|
|
|
$em = EmotionHero\Application::getInstance()->getEm();
|
|
|
|
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()); |