Changeset 6805
- Timestamp:
- 12/29/07 08:37:56 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/config/sfDatabaseConfigHandler.class.php
r6729 r6805 50 50 51 51 // get a list of database connections 52 foreach ($myConfig as $ key=> $dbConfig)52 foreach ($myConfig as $name => $dbConfig) 53 53 { 54 54 // is this category already registered? 55 if (in_array($ key, $databases))55 if (in_array($name, $databases)) 56 56 { 57 57 // this category is already registered 58 throw new sfParseException(sprintf('Configuration file "%s" specifies previously registered category "%s".', $configFiles[0], $ key));58 throw new sfParseException(sprintf('Configuration file "%s" specifies previously registered category "%s".', $configFiles[0], $name)); 59 59 } 60 60 61 61 // add this database 62 $databases[] = $ key;62 $databases[] = $name; 63 63 64 64 // let's do our fancy work … … 66 66 { 67 67 // missing class key 68 throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $ key));68 throw new sfParseException(sprintf('Configuration file "%s" specifies category "%s" with missing class key.', $configFiles[0], $name)); 69 69 } 70 70 … … 72 72 { 73 73 // we have a file to include 74 $file = $this->replaceConstants($dbConfig['file']); 75 $file = $this->replacePath($file); 74 $file = $this->replacePath($this->replaceConstants($dbConfig['file'])); 76 75 77 76 if (!is_readable($file)) … … 86 85 87 86 // parse parameters 87 $parameters = array(); 88 88 if (isset($dbConfig['param'])) 89 89 { 90 foreach ($dbConfig['param'] as &$value)90 foreach ($dbConfig['param'] as $key => $value) 91 91 { 92 $ value= $this->replaceConstants($value);92 $parameters[$key] = $this->replaceConstants($value); 93 93 } 94 95 $parameters = var_export($dbConfig['param'], true);96 94 } 97 else 98 { 99 $parameters = 'null'; 100 } 95 $parameters['name'] = $name; 101 96 102 97 // append new data 103 $data[] = sprintf("\n\$database = new %s(%s, '%s');\n". 104 "\$this->databases['%s'] = \$database;", 105 $dbConfig['class'], $parameters, $key, $key); 98 $data[] = sprintf("\n\$this->databases['%s'] = new %s(%s);", $name, $dbConfig['class'], var_export($parameters, true)); 106 99 } 107 100 108 101 // compile data 109 $retval =sprintf("<?php\n".102 return sprintf("<?php\n". 110 103 "// auto-generated by sfDatabaseConfigHandler\n". 111 104 "// date: %s%s\n%s\n", 112 105 date('Y/m/d H:i:s'), implode("\n", $includes), implode("\n", $data)); 113 114 return $retval;115 106 } 116 107 } branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/database/sfPropelDatabase.class.php
r6370 r6805 32 32 $config = array(); 33 33 34 public function initialize($parameters = null , $name = 'propel')34 public function initialize($parameters = null) 35 35 { 36 36 parent::initialize($parameters); … … 38 38 if (!$this->hasParameter('datasource')) 39 39 { 40 $this->setParameter('datasource', $ name);40 $this->setParameter('datasource', $this->getParameter('name', 'propel')); 41 41 } 42 42