extranet/includes/giant/Bdd/Config.php

30 lines
1.2 KiB
PHP

<?php
require_once(realpath('../includes/lib/Doctrine.php'));
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.'/giant');
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 );
$giantPrice = Doctrine_Manager::connection(DSN, 'giant');
$giantPrice->setCharset('utf8');
Doctrine::loadModels(MODELS_PATH . DIRECTORY_SEPARATOR . 'giant');
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);
}
}
?>