Created
February 19, 2010 04:59
-
-
Save jimbojsb/308445 to your computer and use it in GitHub Desktop.
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
[production] | |
phpSettings.display_startup_errors = 0 | |
phpSettings.display_errors = 0 | |
includePaths.library = APPLICATION_PATH "/../library" | |
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" | |
bootstrap.class = "Bootstrap" | |
pluginPaths.Sonar_Application_Resource_ = "Sonar/Application/Resource" | |
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" | |
resources.doctrine.modelPath = APPLICATION_PATH "/models" | |
[staging : production] | |
[qa : production] | |
phpSettings.display_startup_errors = 1 | |
phpSettings.display_errors = 1 | |
resources.doctrine.connectionString = "mysql://sonar:2ownSonar@localhost" | |
resources.doctrine.databases[] = sonar_qa | |
[development : production] | |
phpSettings.display_startup_errors = 1 | |
phpSettings.display_errors = 1 | |
resources.doctrine.connectionString = "mysql://sonar:2ownSonar@localhost" | |
resources.doctrine.databases[] = sonar | |
<?php | |
class My_Application_Resource_Doctrine extends Zend_Application_Resource_ResourceAbstract | |
{ | |
public function init() | |
{ | |
//pull in options from config file | |
$options = $this->getOptions(); | |
//require doctrine core | |
require_once('Doctrine/lib/Doctrine.php'); | |
//setup autoloading for doctrine core and models | |
$loader = Zend_Loader_Autoloader::getInstance(); | |
$loader->pushAutoLoader(array('Doctrine', 'autoload')); | |
$loader->pushAutoLoader(array('Doctrine', 'modelsAutoLoad')); | |
//tell doctrine to load the models but load them conservatively | |
$manager = Doctrine_Manager::getInstance(); | |
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); | |
$manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true); | |
Doctrine::loadModels($options["modelPath"]); | |
//make database connections | |
foreach ($options["databases"] as $database) { | |
$dsn = $options["connectionString"] . '/' . $database; | |
$manager->openConnection($dsn, $database); | |
} | |
//return doctrine manager as the resource that was bootstrapped | |
return $manager; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment