use sqlite database for install process

This commit is contained in:
Manuel Raynaud
2013-09-16 20:42:18 +02:00
parent 63472b9f80
commit eeb9a0f9eb
2 changed files with 24 additions and 15 deletions

View File

@@ -69,23 +69,32 @@ class Thelia extends Kernel
protected function initPropel()
{
if (file_exists(THELIA_ROOT . '/local/config/database.yml') === false) {
return ;
if (defined('THELIA_INSTALL_MODE') === true) {
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass('thelia', 'sqlite');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration(array(
"classname" => "\Propel\Runtime\Connection\PropelPDO",
"dsn" => "sqlite:".THELIA_ROOT . "/install/thelia.sqlite"
));
$serviceContainer->setConnectionManager('thelia', $manager);
} else {
$definePropel = new DefinePropel(new DatabaseConfiguration(),
Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass('thelia', 'mysql');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration($definePropel->getConfig());
$serviceContainer->setConnectionManager('thelia', $manager);
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
if ($this->isDebug()) {
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
$con->useDebug(true);
}
}
$definePropel = new DefinePropel(new DatabaseConfiguration(),
Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass('thelia', 'mysql');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration($definePropel->getConfig());
$serviceContainer->setConnectionManager('thelia', $manager);
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
if ($this->isDebug()) {
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
$con->useDebug(true);
}
}
/**

BIN
install/thelia.sqlite Normal file

Binary file not shown.