extranet/includes/giant/Bdd/Config.php

34 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2011-04-06 13:13:14 +00:00
/**
* Fichier de configuration pour la gestion de la base de donnée par Doctrine.
*
*/
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);
}
}
?>