-
-
Save doctrinebot/6b60950ed7325ed6606c to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-711 - https://github.com/doctrine/doctrine2/issues/5224
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\Common\ClassLoader, | |
Doctrine\ORM\Configuration, | |
Doctrine\ORM\EntityManager, | |
Doctrine\Common\Cache\ArrayCache, | |
Doctrine\DBAL\Logging\EchoSqlLogger; | |
class Doctrine { | |
public $em = null; | |
public function __construct() | |
{ | |
// load database configuration from CodeIgniter | |
require_once APPPATH.'config/database.php'; | |
// Set up class loading. You could use different autoloaders, provided by your favorite framework, | |
// if you want to. | |
require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php'; | |
$doctrineClassLoader = new ClassLoader('Doctrine', 'c:/xampp/xampplite/htdocs/CodeIgniter_1.7.2/ci/application/libraries'); | |
$doctrineClassLoader->register(); | |
$entitiesClassLoader = new ClassLoader('Entities', 'C:/xampp/xampplite/htdocs/CodeIgniter_1.7.2/ci/application'); | |
$entitiesClassLoader->register(); | |
$proxiesClassLoader = new ClassLoader('Proxies', 'c:/xampp/xampplite/htdocs/CodeIgniter_1.7.2/ci/application/Entities/proxies'); | |
$proxiesClassLoader->register(); | |
// Set up caches | |
$config = new Configuration; | |
$cache = new ArrayCache; | |
$config->setMetadataCacheImpl($cache); | |
$config->setQueryCacheImpl($cache); | |
$driverImpl = $config->newDefaultAnnotationDriver('c:/xampp/xampplite/htdocs/CodeIgniter_1.7.2/ci/application/Entities'); | |
$config->setMetadataDriverImpl($driverImpl); | |
// Proxy configuration | |
$config->setProxyDir('c:/xampp/xampplite/htdocs/CodeIgniter_1.7.2/ci/application/Entities/proxies'); | |
$config->setProxyNamespace('Proxies'); | |
// Set up logger | |
$logger = new EchoSqlLogger; | |
$config->setSqlLogger($logger); | |
$config->setAutoGenerateProxyClasses( TRUE ); | |
// Database connection information | |
$connectionOptions = array( | |
'driver' => 'pdo_mysql', | |
'user' => $db['default']['username'], | |
'password' => $db['default']['password'], | |
'host' => $db['default']['hostname'], | |
'dbname' => $db['default']['database'] | |
); | |
// Create EntityManager | |
$this->em = EntityManager::create($connectionOptions, $config); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment