fix del orden de las tabla en propel
Encontre este patch que mandaron al trunk del symfony parece ser que con esto solucionan el orden de las tablas respecto a los FK + + /** + * Fixes the ordering of foreign key data, by outputting data a foreign key depends on before the table with the foreign key. + * + * @param array The array with the class names. + */ + public function fixOrderingOfForeignKeyData($classes) + { + // reordering classes to take foreign keys into account + for ($i = 0, $count = count($classes); $i < $count; $i++) + { + $class = $classes[$i]; + $tableMap = $this->maps[$class]->getDatabaseMap()->getTable(constant($class.'Peer::TABLE_NAME')); + foreach ($tableMap->getColumns() as $column) + { + if ($column->isForeignKey()) + { + $relatedTable = $this->maps[$class]->getDatabaseMap()->getTable($column->getRelatedTableName()); + $relatedTablePos = array_search($relatedTable->getPhpName(), $classes); + + // check if relatedTable is after the current table + if ($relatedTablePos > $i) + { + // move related table 1 position before current table + $classes = array_merge( + array_slice($classes, 0, $i), + array($classes[$relatedTablePos]), + array_slice($classes, $i, $relatedTablePos - $i), + array_slice($classes, $relatedTablePos + 1) + ); + + // we have moved a table, so let's see if we are done + return $this->fixOrderingOfForeignKeyData($classes); + } + } + } + } + + return $classes; + } } -- Dock Sud BBS http://www.docksud.com.ar telnet://bbs.docksud.com.ar
participants (1)
-
Fernando Toledo