extranet/includes/dbbootstrap.php

37 lines
1.5 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.
*/
require_once 'Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute( Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE );
2009-05-04 14:26:54 +00:00
$manager->setAttribute( Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, TRUE );
$manager->setAttribute( Doctrine::ATTR_USE_NATIVE_ENUM, TRUE );
/*
$manager->setCollate('utf8_unicode_ci');
$manager->setCharset('utf8');
*/
2009-05-13 16:06:14 +00:00
$graydonConn = Doctrine_Manager::connection('mysql://'.MYSQL_USER.':'.MYSQL_PASS.'@'.MYSQL_HOST.'/graydon', 'graydon');
Doctrine::loadModels(realpath(dirname(__FILE__)).'/models/graydon');
$intersudConn = Doctrine_Manager::connection('mysql://'.MYSQL_USER.':'.MYSQL_PASS.'@'.MYSQL_HOST.'/intersud', 'intersud');
Doctrine::loadModels(realpath(dirname(__FILE__)).'/models/intersud');
$sdv1Conn = Doctrine_Manager::connection('mysql://'.MYSQL_USER.':'.MYSQL_PASS.'@'.MYSQL_HOST.'/sdv1', 'sdv1');
Doctrine::loadModels(realpath(dirname(__FILE__)).'/models/sdv1');
/*
$connection->setCollate('utf8_unicode_ci');
$connection->setCharset('utf8');
*/
2009-05-13 16:06:14 +00:00
function setDbConn($name){
global $manager;
$currentName = $manager->getCurrentConnection()->getName();
$currentConn = $manager->getCurrentConnection();
if($currentName != $name){
$manager->closeConnection($currentConn);
2009-05-14 10:08:43 +00:00
$manager->setCurrentConnection($name);
Doctrine::loadModels(realpath(dirname(__FILE__)).'/models/'.$name);
2009-05-13 16:06:14 +00:00
}
}
2009-05-04 14:26:54 +00:00
?>