diff --git a/lib/Doctrine/Data/Import.php b/lib/Doctrine/Data/Import.php index 00c54d76f..730fc32ad 100644 --- a/lib/Doctrine/Data/Import.php +++ b/lib/Doctrine/Data/Import.php @@ -64,7 +64,7 @@ class Doctrine_Data_Import extends Doctrine_Data // If they specified a specific yml file if (end($e) == 'yml') { - $array = array_merge_recursive(Doctrine_Parser::load($dir, $this->getFormat()), $array); + $array = array_merge(Doctrine_Parser::load($dir, $this->getFormat()), $array); // If they specified a directory } else if(is_dir($dir)) { $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), @@ -73,7 +73,7 @@ class Doctrine_Data_Import extends Doctrine_Data foreach ($it as $file) { $e = explode('.', $file->getFileName()); if (in_array(end($e), $this->getFormats())) { - $array = array_merge_recursive(Doctrine_Parser::load($file->getPathName(), $this->getFormat()), $array); + $array = array_merge(Doctrine_Parser::load($file->getPathName(), $this->getFormat()), $array); } } } @@ -172,7 +172,20 @@ class Doctrine_Data_Import extends Doctrine_Data $manager = Doctrine_Manager::getInstance(); foreach ($manager as $connection) { - $connection->flush(); + $objects = array(); + foreach ($this->_importedObjects as $object) { + $objects[] = get_class($object); + } + + $tree = $connection->unitOfWork->buildFlushTree($objects); + + foreach ($tree as $model) { + foreach ($this->_importedObjects as $obj) { + if ($obj instanceof $model) { + $obj->save(); + } + } + } } } diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index 7a7d6a8e2..6a26a2bac 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -103,7 +103,7 @@ class Doctrine_Import_Schema foreach ((array) $schema AS $s) { if (is_file($s)) { - $array = array_merge($array, $this->parseSchema($s, $format)); + $array = array_merge($this->parseSchema($s, $format), $array); } else if (is_dir($s)) { $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($s), RecursiveIteratorIterator::LEAVES_ONLY); @@ -111,7 +111,7 @@ class Doctrine_Import_Schema foreach ($it as $file) { $e = explode('.', $file->getFileName()); if (end($e) === $format) { - $array = array_merge($array, $this->parseSchema($file->getPathName(), $format)); + $array = array_merge($this->parseSchema($file->getPathName(), $format), $array); } } }