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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| protected function _initDoctrine()
{
require_once '../Doctrine/Common/ClassLoader.php';
$loader = new Doctrine\Common\ClassLoader('Doctrine', '../');
$loader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();
$dev = 'development';
if($dev == 'development') {
$cache = new \Doctrine\Common\Cache\ArrayCache;
}
else {
$cache = new \Doctrine\Common\Cache\ApcCache;
}
$entitiesPath = '../src/Ws/EditBundle/Entity';
$proxiesPath = '../src/Ws/EditBundle/Proxy';
$loader = new Doctrine\Common\ClassLoader('Entity', $entitiesPath);
$loader->register();
$loader = new Doctrine\Common\ClassLoader('Repository', $proxiesPath);
$loader->register();
$config = new Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver($entitiesPath);
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir($proxiesPath);
$config->setProxyNamespace('Ws\EditBundle\Proxy');
$config->setAutoGenerateProxyClasses(true);
if($dev == 'development') {
$config->setAutoGenerateProxyClasses(true);
}
else {
$config->setAutoGenerateProxyClasses(false);
}
$connectionOptions = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'xxxxx',
'password' => 'xxxxx',
'dbname' => 'xxxxx',
);
$this->em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
$requete = $this->em->getRepository('MaClass')->find(164);
} |
Partager