Source for file LDatabaseConfiguration.php
Documentation is available at LDatabaseConfiguration.php
* LDatabaseConfiguration class file.
* @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
* @copyright 2005, diemeisterei GmbH. All rights reserved.
* @author $Author: schmunk $
* @version $Revision: 601 $ $Date: 2007-02-24 23:49:30 +0100 (Sa, 24 Feb 2007) $
* @package Phundament.Packages
* Handles propel & creole configurations
* Returns array of master config
* Inits the config handler
public function init($config)
$_logdir= Prado :: getPathOfAlias("Application") . '/runtime/propel/propel.log';
'level' => $this->Application->Parameters['PropelLogLevel'],
$_cpd= & $this->_config['propel']['datasources'];
$xmlObjs= $config->getElementsByTagName('database');
foreach ($xmlObjs AS $xmlObj)
$attrs= $xmlObj->getAttributes();
$connection["phptype"]= $attrs->itemAt("adapter");
$_hs= $attrs->itemAt("hostspec");
$connection["hostspec"]= (!empty ($_hs)) ? $_hs : " ";
$connection["database"]= $attrs->itemAt("database");
$connection["username"]= $attrs->itemAt("username");
$connection["password"]= $attrs->itemAt("password");
#echo $connection["dsn"] = $attrs->itemAt("adapter").":".$attrs->itemAt("database");
// mysql:host=localhost;dbname=ph
#echo $attrs->itemAt("id");
#echo $connection["dsn"] = $attrs->itemAt("adapter").":host=".$attrs->itemAt("hostspec").";dbname=".$attrs->itemAt("database");
#$connection["user"] = $attrs->itemAt("username");
$_cpd[$attrs->itemAt("id")]['adapter']= $attrs->itemAt("adapter");
$_cpd[$attrs->itemAt("id")]['connection']= $connection;
$_cpd['default']= Prado :: getApplication()->getMode();
#$this->_config = include ($masterConfigFile);
$xmlObjs= $config->getElementsByTagName('scan');
foreach ($xmlObjs AS $xmlObj)
$attrs= $xmlObj->getAttributes();
$pkgConfigs= array_merge($pkgConfigs, $this->findConfigurations($attrs->itemAt("namespace"), $attrs->itemAt("prefer")));
foreach ($pkgConfigs AS $config)
Prado :: trace("Config is not an array", 'Lithron.LDatabaseConfiguration');
Prado :: trace("Propel config files parsed & merged", 'Lithron.LDatabaseConfiguration');
#var_dump($this->_config);exit;
private function findConfigurations($alias, $prefer= null)
#Prado :: trace("Searching for LPropel configs ...", 'Lithron.LPropel');
$baseDir= Prado :: getPathOfNamespace($alias);
$pkgDir= $baseDir . "/" . $item;
$lPropelDir= $pkgDir . "/db/propel";
#echo "-conf." . strtolower($this->Application->getModule("geo_ip")->getCountryCode()) . ".php<hr>";
#if (!(substr($item, -9) == "-conf.php"))
if ($prefer == "geo_ip" && strstr($item, "-conf." . strtolower($this->Application->getModule("geo_ip")->getCountryCode()) . ".php"))
$pkgConfigs[$item]= include_once ($lPropelDir . "/" . $item);
Prado :: trace("Found special geo_ip conf '$item' in '$alias'", 'Lithron.LDatabaseConfiguration');
elseif (substr($item, - 9) == "-conf.php")
$pkgConfigs[$item]= include_once ($lPropelDir . "/" . $item);
#Prado :: trace("Found conf '$item' in '$alias'", 'Lithron.LDatabaseConfiguration');
* Adds a package config to the config
private function addConfiguration($masterConfig, $config)
$sources= & $config['propel']['datasources'];
foreach ($sources AS $id => $datasource)
if (isset ($sources[$datasource]))
elseif (!empty ($_ds) && !isset ($sources[$datasource]))
$defaultKey= $masterConfig['propel']['datasources']['default'];
Prado :: trace("Config for '$datasource' not found, assuming '$defaultKey'", 'Lithron.LDatabaseConfiguration');
$masterConfig['propel']['datasources'][$datasource]= $masterConfig['propel']['datasources'][$defaultKey];
Prado :: trace("Config for '$id' added ().", 'Lithron.LDatabaseConfiguration');
$masterConfig['propel']['datasources'][$id]= $datasource;
$masterConfig['propel']['datasources']["'". $id. "'"]= $datasource;
# $masterConfig['propel']['datasources'][$id]['connection'] = $masterConfig['propel']['datasources']["Normal"]['connection'];
# $masterConfig['propel']['datasources'][$id]['adapter'] = $masterConfig['propel']['datasources']["Normal"]['adapter'];
#var_dump($masterConfig);
* Returns a DSN from the config
$c= $config['propel']['datasources'][$name]['connection'];
$prefix= $c['username'] . ":" . $c['password'] . "@";
$dsn= $c['phptype'] . "://" . $prefix . "" . $c['hostspec'] . "/" . $c['database'];
|