46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Bootstrap Doctrine.php, register autoloader specify
|
|
* configuration attributes and load models.
|
|
*/
|
|
define('DOCTRINE_PATH', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lib/doctrine');
|
|
define('MODELS_PATH', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'dbmodels');
|
|
define('DSN', 'mysql://'.MYSQL_USER.':'.MYSQL_PASS.'@'.MYSQL_HOST);
|
|
|
|
require_once(DOCTRINE_PATH . DIRECTORY_SEPARATOR . 'Doctrine.php');
|
|
|
|
spl_autoload_register(array('Doctrine', 'autoload'));
|
|
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
|
|
|
|
$manager = Doctrine_Manager::getInstance();
|
|
$manager->setAttribute( Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE );
|
|
$manager->setAttribute( Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, TRUE );
|
|
$manager->setAttribute( Doctrine::ATTR_USE_NATIVE_ENUM, TRUE );
|
|
|
|
$sdv1Conn = Doctrine_Manager::connection(DSN . '/sdv1', 'sdv1');
|
|
$sdv1Conn->setCharset('utf8');
|
|
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . 'sdv1');
|
|
$graydonConn = Doctrine_Manager::connection(DSN . '/graydon', 'graydon');
|
|
$graydonConn->setCharset('utf8');
|
|
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . 'graydon');
|
|
$intersudConn = Doctrine_Manager::connection(DSN . '/intersud', 'intersud');
|
|
$intersudConn->setCharset('utf8');
|
|
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . 'intersud');
|
|
|
|
$giant = Doctrine_Manager::connection(DSN . '/giantclient', 'giantclient');
|
|
$giant->setCharset('utf8');
|
|
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . 'giantclient');
|
|
|
|
function setDbConn($name){
|
|
global $manager;
|
|
$currentName = $manager->getCurrentConnection()->getName();
|
|
if($currentName != $name){
|
|
//$currentConn = $manager->getCurrentConnection();
|
|
//$manager->closeConnection($currentConn);
|
|
$manager->setCurrentConnection($name);
|
|
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . $name);
|
|
}
|
|
}
|
|
|
|
?>
|