/** * Add foreign keys * @param string $tableDslString [description] * @param CTable $tbl [description] * @param CDialectBase $tables [description] * @param string[] $nullablecols [description] * @param string[] $uniquecols [description] */ private function addForeignKeys(&$tableDslString, $tbl, $tables, $nullablecols, $uniquecols) { $tblName = $tbl->getName(); foreach ($tbl->getForeignKeys() as $fk) { $rel = in_array($fk->getColumnName(), $nullablecols) ? "0..*-0..1" : "0..*-1"; $rel = in_array($fk->getColumnName(), $uniquecols) ? "0..1-1" : $rel; if (!isset($tables[$fk->getForeignTableName()])) { throw new \Exception("table not found"); } $tableDslString .= "\n[{$tblName}]" . $rel . $this->generateTableDslRecursive($tables, $tables[$fk->getForeignTableName()]); } }
/** * Basic function to return the name of the table * @param CTable $table The table in question * @return string The name as shown in the diagram */ public function formatTableName($table) { return $table->getName(); }