Commit 50ab1867 authored by Jonathan.Wage's avatar Jonathan.Wage

Fixes for sql exporting so it will get all loaded models if no directory is specified.

parent f2a7390c
...@@ -101,19 +101,25 @@ class Doctrine_Data_Export extends Doctrine_Data ...@@ -101,19 +101,25 @@ class Doctrine_Data_Export extends Doctrine_Data
if (is_array($directory)) { if (is_array($directory)) {
throw new Doctrine_Data_Exception('You must specify a single path to a folder in order to export individual files.'); throw new Doctrine_Data_Exception('You must specify a single path to a folder in order to export individual files.');
} else if (!is_dir($directory) && is_file($directory)) {
$directory = dirname($directory);
} }
foreach ($data as $className => $classData) { foreach ($data as $className => $classData) {
if (!empty($classData)) {
Doctrine_Parser::dump(array($className => $classData), $format, $directory.DIRECTORY_SEPARATOR.$className.'.'.$format); Doctrine_Parser::dump(array($className => $classData), $format, $directory.DIRECTORY_SEPARATOR.$className.'.'.$format);
} }
}
} else { } else {
if (is_dir($directory)) { if (is_dir($directory)) {
throw new Doctrine_Data_Exception('You must specify the path to a '.$format.' file to export. You specified a directory.'); throw new Doctrine_Data_Exception('You must specify the path to a '.$format.' file to export. You specified a directory.');
} }
if (!empty($data)) {
return Doctrine_Parser::dump($data, $format, $directory); return Doctrine_Parser::dump($data, $format, $directory);
} }
} }
}
/** /**
* prepareData * prepareData
* *
......
...@@ -978,9 +978,9 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -978,9 +978,9 @@ class Doctrine_Export extends Doctrine_Connection_Module
public function exportSchema($directory = null) public function exportSchema($directory = null)
{ {
if ($directory !== null) { if ($directory !== null) {
$models = Doctrine::loadModels($directory); $models = Doctrine_Facade::loadModels($directory);
} else { } else {
$models = Doctrine::getLoadedModels(); $models = Doctrine_Facade::getLoadedModels();
} }
$this->exportClasses($models); $this->exportClasses($models);
...@@ -1058,7 +1058,7 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -1058,7 +1058,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/ */
public function exportClassesSql(array $classes) public function exportClassesSql(array $classes)
{ {
$models = Doctrine::getLoadedModels($classes); $models = Doctrine_Facade::getLoadedModels($classes);
$sql = array(); $sql = array();
...@@ -1136,7 +1136,11 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -1136,7 +1136,11 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/ */
public function exportSql($directory = null) public function exportSql($directory = null)
{ {
$models = Doctrine::loadModels($directory); if ($directory !== null) {
$models = Doctrine_Facade::loadModels($directory);
} else {
$models = Doctrine_Facade::getLoadedModels();
}
return $this->exportClassesSql($models); return $this->exportClassesSql($models);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment