1
0
mirror of synced 2024-12-13 14:56:01 +03:00

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

This commit is contained in:
Jonathan.Wage 2007-10-16 02:37:31 +00:00
parent f2a7390c29
commit 50ab186792
2 changed files with 17 additions and 7 deletions

View File

@ -101,17 +101,23 @@ class Doctrine_Data_Export extends Doctrine_Data
if (is_array($directory)) {
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) {
Doctrine_Parser::dump(array($className => $classData), $format, $directory.DIRECTORY_SEPARATOR.$className.'.'.$format);
if (!empty($classData)) {
Doctrine_Parser::dump(array($className => $classData), $format, $directory.DIRECTORY_SEPARATOR.$className.'.'.$format);
}
}
} else {
if (is_dir($directory)) {
throw new Doctrine_Data_Exception('You must specify the path to a '.$format.' file to export. You specified a directory.');
}
return Doctrine_Parser::dump($data, $format, $directory);
if (!empty($data)) {
return Doctrine_Parser::dump($data, $format, $directory);
}
}
}
/**

View File

@ -978,9 +978,9 @@ class Doctrine_Export extends Doctrine_Connection_Module
public function exportSchema($directory = null)
{
if ($directory !== null) {
$models = Doctrine::loadModels($directory);
$models = Doctrine_Facade::loadModels($directory);
} else {
$models = Doctrine::getLoadedModels();
$models = Doctrine_Facade::getLoadedModels();
}
$this->exportClasses($models);
@ -1058,7 +1058,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/
public function exportClassesSql(array $classes)
{
$models = Doctrine::getLoadedModels($classes);
$models = Doctrine_Facade::getLoadedModels($classes);
$sql = array();
@ -1136,8 +1136,12 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/
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);
}
/**