/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Bootstrap.php function _initDoctrine() { // setup configuration as seen from the sandbox application // TODO: read configuration from application.ini $config = new \Doctrine\ORM\Configuration; $cache = new \Doctrine\Common\Cache\ArrayCache; $config->setMetadataCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver('../Application/Entities'); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setProxyDir('../Application/Proxies'); $config->setProxyNamespace('Application\Proxies'); $config->setAutoGenerateProxyClasses(true); 'driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'learningzf' ); // setup entity manager $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); Zend_Registry::set("em", $em); return $em; } // now i can access the entity manager from anywhere thru $em = Zend_Registry::get('em'); // application.ini // autoloading Doctrine, Symfony & Application namespace classes. my Doctrine entities are found in library/Application/Entities autoloaderNamespaces[] = Doctrine autoloaderNamespaces[] = Symfony autoloaderNamespaces[] = Application