1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <?php
require 'Doctrine/Common/ClassLoader.php';
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Configuration;
//Autoloader
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();
$classloader = new \Doctrine\Common\ClassLoader('Symfony');
$classloader->register();
//Configuration
$config = new Configuration();
$driverImpl = $config->newDefaultAnnotationDriver('/Entities');
$config->setMetadataDriverImpl($driverImpl);
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$connectionParams = array(
'dbname' => 'doctrine_db',
'user' => 'root',
'password' => '',
'host' => 'localhost',
'driver' => 'pdo_mysql',
);
$em = EntityManager::create($connectionParams, $config); |
Partager