diff --git a/lib/Doctrine/Data/Export.php b/lib/Doctrine/Data/Export.php index 6bb1fbf7b..eae6d57d6 100644 --- a/lib/Doctrine/Data/Export.php +++ b/lib/Doctrine/Data/Export.php @@ -140,6 +140,17 @@ class Doctrine_Data_Export extends Doctrine_Data continue; } + // skip single primary keys, we need to maintain composite primary keys + $keys = $record->getTable()->getIdentifier(); + + if (!is_array($keys)) { + $keys = array($keys); + } + + if (count($keys) <= 1 && in_array($key, $keys)) { + continue; + } + if ($relation = $this->isRelation($record, $key)) { $relationAlias = $relation['alias']; $relationRecord = $record->$relationAlias; @@ -160,18 +171,7 @@ class Doctrine_Data_Export extends Doctrine_Data $relationValue = $relationClassName . '_' . $value; $preparedData[$className][$recordKey][$relationClassName] = $relationValue; - } else { - // skip single primary keys, we need to maintain composite primary keys - $keys = $record->getTable()->getIdentifier(); - - if (!is_array($keys)) { - $keys = array($keys); - } - - if (count($keys) <= 1 && in_array($key, $keys)) { - continue; - } - + } else { $preparedData[$className][$recordKey][$key] = $value; } } diff --git a/lib/Doctrine/Import/Builder.php b/lib/Doctrine/Import/Builder.php index cbfe0211c..b1f866d5d 100644 --- a/lib/Doctrine/Import/Builder.php +++ b/lib/Doctrine/Import/Builder.php @@ -193,7 +193,7 @@ END; } if (!empty($ret)) { - return "\n\t\tpublic function setTableDefinition()"."\n\t\t{\n".implode("\n", $ret)."\n\t\t}"; + return "\n\tpublic function setTableDefinition()"."\n\t{\n".implode("\n", $ret)."\n\t}"; } } public function buildSetUp(array $options, array $columns, array $relations) @@ -264,7 +264,7 @@ END; } if (!empty($ret)) { - return "\n\t\tpublic function setUp()\n\t\t{\n".implode("\n", $ret)."\n\t\t}"; + return "\n\tpublic function setUp()\n\t{\n".implode("\n", $ret)."\n\t}"; } } @@ -311,11 +311,14 @@ END; if ($this->generateBaseClasses()) { // We only want to generate this one if it doesn't already exist - if (!file_exists($options['fileName'])) { + if (file_exists($options['fileName'])) { $optionsBak = $options; unset($options['tableName']); $options['inheritance']['extends'] = 'Base' . $options['className']; + $options['requires'] = array($this->baseClassesDirectory . DIRECTORY_SEPARATOR . $options['inheritance']['extends'] . $this->suffix); + $options['no_definition'] = true; + $this->writeDefinition($options, array(), array()); $options = $optionsBak; @@ -341,7 +344,21 @@ END; { $content = $this->buildDefinition($options, $columns, $relations); - $bytes = file_put_contents($options['fileName'], 'setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL); -//Doctrine::loadModels('test_models'); +Doctrine::loadModels('test_models'); -$import = new Doctrine_Import_Schema(); -$import->generateBaseClasses(true); -$import->importSchema('schema.yml', 'yml', 'test_models'); \ No newline at end of file +$data = new Doctrine_Data(); +$data->importData('fixtures.yml'); \ No newline at end of file