Created
October 29, 2012 22:14
-
-
Save danielalvarenga/3976896 to your computer and use it in GitHub Desktop.
Gerar tabelas automático com Doctrine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Doctrine\ORM\Tools\Setup; | |
use Doctrine\ORM\EntityManager; | |
require_once "classes/Admin.php"; | |
require_once "classes/Log.php"; | |
require_once "classes/Usuario.php"; | |
require_once "classes/PremiosUsuario.php"; | |
require_once "classes/Aposta.php"; | |
require_once "classes/Time.php"; | |
require_once "classes/Pais.php"; | |
require_once "classes/Jogo.php"; | |
require_once "classes/Rodada.php"; | |
require_once "classes/Campeonato.php"; | |
require_once "classes/RendimentoTime.php"; | |
require_once "classes/PontuacaoRodada.php"; | |
require_once "classes/PontuacaoGeral.php"; | |
require_once "classes/ContadorAposta.php"; | |
//require_once "Doctrine/ORM/Tools/Setup.php"; | |
//Setup::registerAutoloadPEAR(); | |
require_once 'Doctrine/Common/ClassLoader.php'; | |
$loader = new \Doctrine\Common\ClassLoader("Doctrine"); | |
$loader->register(); | |
// Configuracao de acesso ao banco de dados | |
$conn = array( | |
'driver' => 'pdo_mysql', | |
'user' => 'root', | |
'password' => 'password', | |
'dbname' => 'database' | |
); | |
$debug = true; | |
$path = array(__DIR__."/classes"); | |
$config = Setup::createAnnotationMetadataConfiguration($path, $debug); | |
// Obtendo uma instancia do Entity Manager | |
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'bootstrap.php'; | |
$em = $entityManager; | |
$tool = new \Doctrine\ORM\Tools\SchemaTool($em); | |
$classes = array( | |
$em->getClassMetadata('Admin'), | |
$em->getClassMetadata('Log'), | |
$em->getClassMetadata('Pais'), | |
$em->getClassMetadata('Time'), | |
$em->getClassMetadata('Campeonato'), | |
$em->getClassMetadata('RendimentoTime'), | |
$em->getClassMetadata('Rodada'), | |
$em->getClassMetadata('Jogo'), | |
$em->getClassMetadata('Usuario'), | |
$em->getClassMetadata('Aposta'), | |
$em->getClassMetadata('ContadorAposta'), | |
$em->getClassMetadata('PremiosUsuario'), | |
$em->getClassMetadata('PontuacaoRodada'), | |
$em->getClassMetadata('PontuacaoGeral') | |
); | |
$tool->dropSchema($classes); // remove banco de dados | |
//$tool->createSchema($classes); // cria novo banco de dados | |
//$tool->updateSchema($classes); // atualiza o banco de dados | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment