extranet/includes/dbbootstrap.php

46 lines
1.8 KiB
PHP
Raw Normal View History

2009-05-04 14:26:54 +00:00
<?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');
2009-05-04 14:26:54 +00:00
spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
2009-05-04 14:26:54 +00:00
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute( Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE );
2010-04-20 12:58:22 +00:00
$manager->setAttribute( Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, TRUE );
$manager->setAttribute( Doctrine::ATTR_USE_NATIVE_ENUM, TRUE );
2010-04-20 12:58:22 +00:00
$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');
2010-04-20 12:58:22 +00:00
2010-08-31 13:55:19 +00:00
$giant = Doctrine_Manager::connection(DSN . '/giantclient', 'giantclient');
$giant->setCharset('utf8');
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . 'giantclient');
2009-05-13 16:06:14 +00:00
function setDbConn($name){
global $manager;
$currentName = $manager->getCurrentConnection()->getName();
if($currentName != $name){
//$currentConn = $manager->getCurrentConnection();
//$manager->closeConnection($currentConn);
2009-05-14 10:08:43 +00:00
$manager->setCurrentConnection($name);
2010-04-21 15:59:06 +00:00
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . $name);
2009-05-13 16:06:14 +00:00
}
}
2010-05-18 15:46:45 +00:00
?>