本文整理汇总了PHP中ForeignKey类的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey类的具体用法?PHP ForeignKey怎么用?PHP ForeignKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ForeignKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate()
{
$isSubmitted = false;
$sql = false;
$foreignKey = ForeignKey::model()->findBySql('SELECT * FROM KEY_COLUMN_USAGE ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'AND COLUMN_NAME = :columnName ' . 'AND REFERENCED_TABLE_SCHEMA IS NOT NULL', array('tableSchema' => $this->schema, 'tableName' => $this->table, 'columnName' => $this->column));
if (!$foreignKey) {
$foreignKey = new ForeignKey();
$foreignKey->TABLE_SCHEMA = $this->schema;
$foreignKey->TABLE_NAME = $this->table;
$foreignKey->COLUMN_NAME = $this->column;
}
if (isset($_POST['ForeignKey'])) {
$foreignKey->attributes = $_POST['ForeignKey'];
if ($foreignKey->getReferences() && ($sql = $foreignKey->save())) {
$isSubmitted = true;
} elseif (!$foreignKey->getReferences() && ($sql = $foreignKey->delete())) {
$isSubmitted = true;
}
}
CHtml::generateRandomIdPrefix();
// Column data
$columns = array('' => '');
$tables = Table::model()->findAllByAttributes(array('TABLE_SCHEMA' => $this->schema));
foreach ($tables as $table) {
if (StorageEngine::check($table->ENGINE, StorageEngine::SUPPORTS_FOREIGN_KEYS)) {
$columns[$table->TABLE_NAME] = array();
foreach ($table->columns as $column) {
$columns[$table->TABLE_NAME][$this->schema . '.' . $table->TABLE_NAME . '.' . $column->COLUMN_NAME] = $column->COLUMN_NAME;
}
}
}
// "On-Actions"
$onActions = array('' => '', 'CASCADE' => 'CASCADE', 'SET NULL' => 'SET NULL', 'NO ACTION' => 'NO ACTION', 'RESTRICT' => 'RESTRICT');
$this->render('form', array('foreignKey' => $foreignKey, 'columns' => $columns, 'onActions' => $onActions, 'sql' => $sql, 'isSubmitted' => $isSubmitted));
}
示例2: addRefFKGet
/**
* Adds the method that returns the referrer fkey collection.
* @param string &$script The script will be modified in this method.
*/
protected function addRefFKGet(&$script, ForeignKey $refFK)
{
$table = $this->getTable();
$tblFK = $refFK->getTable();
$peerClassname = $this->getStubPeerBuilder()->getClassname();
$fkPeerBuilder = $this->getNewPeerBuilder($refFK->getTable());
$relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
$collName = $this->getRefFKCollVarName($refFK);
$lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
$className = $fkPeerBuilder->getObjectClassname();
$script .= "\n\t/**\n\t * Gets an array of {$className} objects which contain a foreign key that references this object.\n\t *\n\t * If this collection has already been initialized with an identical Criteria, it returns the collection.\n\t * Otherwise if this " . $this->getObjectClassname() . " has previously been saved, it will retrieve\n\t * related {$relCol} from storage. If this " . $this->getObjectClassname() . " is new, it will return\n\t * an empty collection or the current collection, the criteria is ignored on a new object.\n\t *\n\t * @param PropelPDO \$con\n\t * @param Criteria \$criteria\n\t * @return array {$className}[]\n\t * @throws PropelException\n\t */\n\tpublic function get{$relCol}(\$criteria = null, PropelPDO \$con = null, array \$selectedColumns = null)\n\t{";
$script .= "\n\t\tif (\$criteria === null) {\n\t\t\t\$criteria = new Criteria({$peerClassname}::DATABASE_NAME);\n\t\t}\n\t\telseif (\$criteria instanceof Criteria)\n\t\t{\n\t\t\t\$criteria = clone \$criteria;\n\t\t}\n\n\t\tif (\$this->{$collName} === null) {\n\t\t\tif (\$this->isNew()) {\n\t\t\t \$this->{$collName} = array();\n\t\t\t} else {\n";
foreach ($refFK->getLocalColumns() as $colFKName) {
// $colFKName is local to the referring table (i.e. foreign to this table)
$lfmap = $refFK->getLocalForeignMapping();
$localColumn = $this->getTable()->getColumn($lfmap[$colFKName]);
$colFK = $refFK->getTable()->getColumn($colFKName);
$clo = strtolower($localColumn->getName());
$script .= "\n\t\t\t\t\$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->{$clo});\n";
}
// end foreach ($fk->getForeignColumns()
$script .= "\n if (null !== \$selectedColumns) {\n " . $fkPeerBuilder->getPeerClassname() . "::setSelectedColumns(\$selectedColumns);\n }\n\t\t\t\t" . $fkPeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria);\n\t\t\t\t\$this->{$collName} = " . $fkPeerBuilder->getPeerClassname() . "::doSelect(\$criteria, \$con);\n\t\t\t}\n\t\t} else {\n\t\t\t// criteria has no effect for a new object\n\t\t\tif (!\$this->isNew()) {\n\t\t\t\t// the following code is to determine if a new query is\n\t\t\t\t// called for. If the criteria is the same as the last\n\t\t\t\t// one, just return the collection.\n";
foreach ($refFK->getLocalColumns() as $colFKName) {
// $colFKName is local to the referring table (i.e. foreign to this table)
$lfmap = $refFK->getLocalForeignMapping();
$localColumn = $this->getTable()->getColumn($lfmap[$colFKName]);
$colFK = $refFK->getTable()->getColumn($colFKName);
$clo = strtolower($localColumn->getName());
$script .= "\n\n\t\t\t\t\$criteria->add(" . $fkPeerBuilder->getColumnConstant($colFK) . ", \$this->{$clo});\n";
}
// foreach ($fk->getForeignColumns()
$script .= "\n if (null !== \$selectedColumns) {\n " . $fkPeerBuilder->getPeerClassname() . "::setSelectedColumns(\$selectedColumns);\n }\n\t\t\t\t" . $fkPeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria);\n\t\t\t\tif (!isset(\$this->{$lastCriteriaName}) || !\$this->" . $lastCriteriaName . "->equals(\$criteria)) {\n\t\t\t\t\t\$this->{$collName} = " . $fkPeerBuilder->getPeerClassname() . "::doSelect(\$criteria, \$con);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\$this->{$lastCriteriaName} = \$criteria;\n\t\treturn \$this->{$collName};\n\t}\n";
}
示例3: relateI18nTableToMainTable
protected function relateI18nTableToMainTable()
{
$table = $this->getTable();
$i18nTable = $this->i18nTable;
$pks = $this->getTable()->getPrimaryKey();
if (count($pks) > 1) {
throw new EngineException('The i18n behavior does not support tables with composite primary keys');
}
foreach ($pks as $column) {
if (!$i18nTable->hasColumn($column->getName())) {
$column = clone $column;
$column->setAutoIncrement(false);
$i18nTable->addColumn($column);
}
}
if (in_array($table->getName(), $i18nTable->getForeignTableNames())) {
return;
}
$fk = new ForeignKey();
$fk->setForeignTableCommonName($table->getCommonName());
$fk->setForeignSchemaName($table->getSchema());
$fk->setDefaultJoin('LEFT JOIN');
$fk->setOnDelete(ForeignKey::CASCADE);
$fk->setOnUpdate(ForeignKey::NONE);
foreach ($pks as $column) {
$fk->addReference($column->getName(), $column->getName());
}
$i18nTable->addForeignKey($fk);
}
示例4: actionStructure
/**
* Shows the table structure
*/
public function actionStructure()
{
$table = $this->loadTable();
if (!$table instanceof Table) {
$response = new AjaxResponse();
$response->addNotification("error", Yii::t("core", "tableLoadErrorTitle", array("{table}" => $this->table)), Yii::t("core", "tableLoadErrorMessage", array("{table}" => $this->table)));
$response->executeJavaScript("sideBar.loadTables(schema)");
$this->sendJSON($response);
}
// Constraints
if (StorageEngine::check($table->ENGINE, StorageEngine::SUPPORTS_FOREIGN_KEYS)) {
$foreignKeys = array();
$sql = 'SELECT * FROM KEY_COLUMN_USAGE ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'AND REFERENCED_TABLE_SCHEMA IS NOT NULL';
$table->foreignKeys = ForeignKey::model()->findAllBySql($sql, array('tableSchema' => $table->TABLE_SCHEMA, 'tableName' => $table->TABLE_NAME));
foreach ($table->foreignKeys as $key) {
$foreignKeys[] = $key->COLUMN_NAME;
}
} else {
$foreignKeys = false;
}
// Indices
$sql = 'SELECT * FROM STATISTICS ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'GROUP BY INDEX_NAME ' . 'ORDER BY INDEX_NAME = \'PRIMARY\' DESC, INDEX_NAME';
$table->indices = Index::model()->findAllBySql($sql, array('tableSchema' => $table->TABLE_SCHEMA, 'tableName' => $table->TABLE_NAME));
foreach ($table->indices as $index) {
$index->columns = IndexColumn::model()->findAllByAttributes(array('TABLE_SCHEMA' => $table->TABLE_SCHEMA, 'TABLE_NAME' => $table->TABLE_NAME, 'INDEX_NAME' => $index->INDEX_NAME));
}
// Indices (seperate for each column)
$indicesRaw = Index::model()->findAllByAttributes(array('TABLE_SCHEMA' => $table->TABLE_SCHEMA, 'TABLE_NAME' => $table->TABLE_NAME));
// Triggers
$table->triggers = Trigger::model()->findAllByAttributes(array('EVENT_OBJECT_SCHEMA' => $table->TABLE_SCHEMA, 'EVENT_OBJECT_TABLE' => $table->TABLE_NAME));
$this->render('structure', array('table' => $table, 'canAlter' => Yii::app()->user->privileges->checkTable($table->TABLE_SCHEMA, $table->TABLE_NAME, 'ALTER'), 'foreignKeys' => $foreignKeys, 'indicesRaw' => $indicesRaw));
}
示例5: modifyTable
public function modifyTable()
{
$parentTable = $this->getParentTable();
if (count($parentTable->getPrimaryKey()) > 1) {
throw new RuntimeException('Equal nest works only with a single primary key for the parent table');
}
$parentTablePrimaryKey = $parentTable->getPrimaryKey();
if (!$this->getTable()->hasColumn($this->getReferenceColumn1Name())) {
$this->getTable()->addColumn(array('name' => $this->getReferenceColumn1Name(), 'primaryKey' => 'true', 'type' => $parentTablePrimaryKey[0]->getType()));
$fk = new ForeignKey();
$fk->setName($this->getReferenceColumn1Name());
$fk->setForeignTableCommonName($this->getParentTable()->getCommonName());
$fk->setOnDelete(ForeignKey::CASCADE);
$fk->setOnUpdate(null);
$fk->addReference($this->getReferenceColumn1Name(), $parentTablePrimaryKey[0]->getName());
$this->getTable()->addForeignKey($fk);
}
if (!$this->getTable()->hasColumn($this->getReferenceColumn2Name())) {
$this->getTable()->addColumn(array('name' => $this->getReferenceColumn2Name(), 'primaryKey' => 'true', 'type' => $parentTablePrimaryKey[0]->getType()));
$fk = new ForeignKey();
$fk->setName($this->getReferenceColumn2Name());
$fk->setForeignTableCommonName($this->getParentTable()->getCommonName());
$fk->setOnDelete(ForeignKey::CASCADE);
$fk->setOnUpdate(null);
$fk->addReference($this->getReferenceColumn2Name(), $parentTablePrimaryKey[0]->getName());
$this->getTable()->addForeignKey($fk);
}
if (!$parentTable->hasBehavior('equal_nest_parent')) {
$parentBehavior = new EqualNestParentBehavior();
$parentBehavior->setName('equal_nest_parent');
$parentBehavior->addParameter(array('name' => 'middle_table', 'value' => $this->getTable()->getName()));
$parentTable->addBehavior($parentBehavior);
}
$this->parentBehavior = $parentTable->getBehavior('equal_nest_parent');
}
示例6: addRelation
private function addRelation($oLocalColumn, $oUsersTable, $oUsersId)
{
$oFk = new ForeignKey();
$oFk->setTable($this->getTable());
$oFk->setForeignTableCommonName($oUsersTable->getName());
if (!$oFk->isMatchedByInverseFK()) {
$oFk->setOnDelete(ForeignKey::SETNULL);
$oFk->setOnUpdate(null);
$oFk->addReference($oLocalColumn, $oUsersId);
$this->getTable()->addForeignKey($oFk);
}
}
示例7: relateDelegateToMainTable
protected function relateDelegateToMainTable($delegateTable, $mainTable)
{
$pks = $mainTable->getPrimaryKey();
foreach ($pks as $column) {
$mainColumnName = $column->getName();
if (!$delegateTable->hasColumn($mainColumnName)) {
$column = clone $column;
$column->setAutoIncrement(false);
$delegateTable->addColumn($column);
}
}
// Add a one-to-one fk
$fk = new ForeignKey();
$fk->setForeignTableCommonName($mainTable->getCommonName());
$fk->setForeignSchemaName($mainTable->getSchema());
$fk->setDefaultJoin('LEFT JOIN');
$fk->setOnDelete(ForeignKey::CASCADE);
$fk->setOnUpdate(ForeignKey::NONE);
foreach ($pks as $column) {
$fk->addReference($column->getName(), $column->getName());
}
$delegateTable->addForeignKey($fk);
}
示例8: __construct
private function __construct($sql)
{
preg_match('/^CREATE TABLE (?<name>[^\\s\\(]+) \\((?<defs>.*)\\)\\s*$/is', $sql, $matches);
$this->m_name = $matches['name'];
$defs = array_map('trim', preg_split('/,[\\t ]*[\\r\\n]/', $matches['defs']));
$this->m_columns = [];
$this->m_foreign = [];
$this->m_unique = [];
$constraints = [];
foreach ($defs as $def) {
if (count($constraints) || ($matched = self::match('(?:CONSTRAINT|PRIMARY|UNIQUE|FOREIGN|CHECK)\\b', $def, $m))) {
if (isset($matched) && !$matched) {
throw new \Exception('Failed to parse start of constraint');
}
// table constraint
// check for optional constraint name
$constraintName = NULL;
if (self::match('CONSTRAINT (?<name>' . Column::R_NAME . ')', $def, $m)) {
$constraintName = $m['name'];
$def = ltrim(substr($def, strlen($m[0])));
}
if ($uniqueKey = UniqueKey::parse($constraintName, $def)) {
$this->m_unique[] = $uniqueKey;
} else {
if ($foreignKey = ForeignKey::parse($constraintName, $def)) {
$this->m_foreign[$foreignKey->localField()] = $foreignKey;
} else {
throw new \Exception('Failed to parse constraint');
}
}
} else {
$column = Column::parse($def);
$this->m_columns[$column->name()] = $column;
}
}
}
示例9: getRelatedBySuffix
/**
* Gets the "RelatedBy*" suffix (if needed) that is attached to method and variable names.
*
* The related by suffix is based on the local columns of the foreign key. If there is more than
* one column in a table that points to the same foreign table, then a 'RelatedByLocalColName' suffix
* will be appended.
*
* @return string
*/
protected function getRelatedBySuffix(ForeignKey $fk, $columnCheck = false)
{
$relCol = "";
foreach ($fk->getLocalColumns() as $columnName) {
$column = $fk->getTable()->getColumn($columnName);
if (!$column) {
throw new Exception("Could not fetch column: {$columnName} in table " . $fk->getTable()->getName());
}
if (count($column->getTable()->getForeignKeysReferencingTable($fk->getForeignTableName())) > 1 || $fk->getForeignTableName() == $fk->getTable()->getName()) {
// if there are seeral foreign keys that point to the same table
// then we need to generate methods like getAuthorRelatedByColName()
// instead of just getAuthor(). Currently we are doing the same
// for self-referential foreign keys, to avoid confusion.
$relCol .= $column->getPhpName();
}
}
#var_dump($fk->getForeignTableName() . ' - ' .$fk->getTableName() . ' - ' . $this->getTable()->getName());
#$fk->getForeignTableName() != $this->getTable()->getName() &&
// @todo comment on it
if ($columnCheck && !$relCol && $fk->getTable()->getColumn($fk->getForeignTableName())) {
foreach ($fk->getLocalColumns() as $columnName) {
$column = $fk->getTable()->getColumn($columnName);
$relCol .= $column->getPhpName();
}
}
if ($relCol != "") {
$relCol = "RelatedBy" . $relCol;
}
return $relCol;
}
示例10: addForeignKeys
/**
* Load foreign keys for this table.
*
* @param Table $table The Table model class to add FKs to
*/
protected function addForeignKeys(Table $table)
{
// local store to avoid duplicates
$foreignKeys = array();
$stmt = $this->dbh->query("SELECT CONSTRAINT_NAME, DELETE_RULE, R_CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'R' AND TABLE_NAME = '" . $table->getName() . "'");
/* @var stmt PDOStatement */
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
// Local reference
$stmt2 = $this->dbh->query("SELECT COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '" . $row['CONSTRAINT_NAME'] . "' AND TABLE_NAME = '" . $table->getName() . "'");
/* @var stmt2 PDOStatement */
$localReferenceInfo = $stmt2->fetch(PDO::FETCH_ASSOC);
// Foreign reference
$stmt2 = $this->dbh->query("SELECT TABLE_NAME, COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '" . $row['R_CONSTRAINT_NAME'] . "'");
$foreignReferenceInfo = $stmt2->fetch(PDO::FETCH_ASSOC);
if (!isset($foreignKeys[$row["CONSTRAINT_NAME"]])) {
$fk = new ForeignKey($row["CONSTRAINT_NAME"]);
$fk->setForeignTableCommonName($foreignReferenceInfo['TABLE_NAME']);
$onDelete = $row["DELETE_RULE"] == 'NO ACTION' ? 'NONE' : $row["DELETE_RULE"];
$fk->setOnDelete($onDelete);
$fk->setOnUpdate($onDelete);
$fk->addReference(array("local" => $localReferenceInfo['COLUMN_NAME'], "foreign" => $foreignReferenceInfo['COLUMN_NAME']));
$table->addForeignKey($fk);
$foreignKeys[$row["CONSTRAINT_NAME"]] = $fk;
}
}
}
示例11: getReferrerVersionsColumn
public function getReferrerVersionsColumn(ForeignKey $fk)
{
$fkTableName = $fk->getTable()->getName();
$fkIdsColumnName = $fkTableName . '_versions';
return $this->versionTable->getColumn($fkIdsColumnName);
}
示例12: getForeignKeyDDL
public function getForeignKeyDDL(ForeignKey $fk)
{
$pattern = "\n-- SQLite does not support foreign keys; this is just for reference\n-- FOREIGN KEY (%s) REFERENCES %s (%s)\n";
return sprintf($pattern, $this->getColumnListDDL($fk->getLocalColumns()), $fk->getForeignTableName(), $this->getColumnListDDL($fk->getForeignColumns()));
}
示例13: foreignAssociation
/**
* Criar a ForeignKey da Associação.
* @param $column
* @param $other_table
* @param null $name
* @param null $other_key
* @return \Illuminate\Support\Fluent
*/
public function foreignAssociation($column, $other_table, $name = null, $other_key = null)
{
$name = is_null($name) ? ForeignKey::makeName($this->table, $column) : $name;
$other_key = is_null($other_key) ? self::keyAttr() : $other_key;
$fk = $this->foreign($column, $name);
$fk->on($other_table);
$fk->references($other_key);
return $fk;
}
示例14: addForeignKeys
/**
* Load foreign keys for this table.
*/
protected function addForeignKeys(Table $table)
{
$database = $table->getDatabase();
$stmt = $this->dbh->query("SELECT ccu1.TABLE_NAME, ccu1.COLUMN_NAME, ccu2.TABLE_NAME AS FK_TABLE_NAME, ccu2.COLUMN_NAME AS FK_COLUMN_NAME\n FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu1 INNER JOIN\n INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc1 ON tc1.CONSTRAINT_NAME = ccu1.CONSTRAINT_NAME AND\n CONSTRAINT_TYPE = 'Foreign Key' INNER JOIN\n INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1 ON rc1.CONSTRAINT_NAME = tc1.CONSTRAINT_NAME INNER JOIN\n INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu2 ON ccu2.CONSTRAINT_NAME = rc1.UNIQUE_CONSTRAINT_NAME\n WHERE (ccu1.table_name = '" . $table->getName() . "')");
$foreignKeys = array();
// local store to avoid duplicates
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$lcol = $row['COLUMN_NAME'];
$ftbl = $row['FK_TABLE_NAME'];
$fcol = $row['FK_COLUMN_NAME'];
$foreignTable = $database->getTable($ftbl);
$foreignColumn = $foreignTable->getColumn($fcol);
$localColumn = $table->getColumn($lcol);
if (!isset($foreignKeys[$name])) {
$fk = new ForeignKey($name);
$fk->setForeignTableCommonName($foreignTable->getCommonName());
$fk->setForeignSchemaName($foreignTable->getSchema());
//$fk->setOnDelete($fkactions['ON DELETE']);
//$fk->setOnUpdate($fkactions['ON UPDATE']);
$table->addForeignKey($fk);
$foreignKeys[$name] = $fk;
}
$foreignKeys[$name]->addReference($localColumn, $foreignColumn);
}
}
示例15: modifyTable
public function modifyTable()
{
$table = $this->getTable();
$parentTable = $this->getParentTable();
if ($this->isCopyData()) {
// tell the parent table that it has a descendant
if (!$parentTable->hasBehavior('concrete_inheritance_parent')) {
$parentBehavior = new ConcreteInheritanceParentBehavior();
$parentBehavior->setName('concrete_inheritance_parent');
$parentBehavior->addParameter(array('name' => 'descendant_column', 'value' => $this->getParameter('descendant_column')));
$parentTable->addBehavior($parentBehavior);
// The parent table's behavior modifyTable() must be executed before this one
$parentBehavior->getTableModifier()->modifyTable();
$parentBehavior->setTableModified(true);
}
}
// Add the columns of the parent table
foreach ($parentTable->getColumns() as $column) {
if ($column->getName() == $this->getParameter('descendant_column')) {
continue;
}
if ($table->containsColumn($column->getName())) {
continue;
}
$copiedColumn = clone $column;
if ($column->isAutoIncrement() && $this->isCopyData()) {
$copiedColumn->setAutoIncrement(false);
}
$table->addColumn($copiedColumn);
if ($column->isPrimaryKey() && $this->isCopyData()) {
$fk = new ForeignKey();
$fk->setForeignTableCommonName($column->getTable()->getCommonName());
$fk->setForeignSchemaName($column->getTable()->getSchema());
$fk->setOnDelete('CASCADE');
$fk->setOnUpdate(null);
$fk->addReference($copiedColumn, $column);
$fk->isParentChild = true;
$table->addForeignKey($fk);
}
}
// add the foreign keys of the parent table
foreach ($parentTable->getForeignKeys() as $fk) {
$copiedFk = clone $fk;
$copiedFk->setName('');
$copiedFk->setRefPhpName('');
$this->getTable()->addForeignKey($copiedFk);
}
// add the validators of the parent table
foreach ($parentTable->getValidators() as $validator) {
$copiedValidator = clone $validator;
$this->getTable()->addValidator($copiedValidator);
}
// add the indices of the parent table
foreach ($parentTable->getIndices() as $index) {
$copiedIndex = clone $index;
$copiedIndex->setName('');
$this->getTable()->addIndex($copiedIndex);
}
// add the unique indices of the parent table
foreach ($parentTable->getUnices() as $unique) {
$copiedUnique = clone $unique;
$copiedUnique->setName('');
$this->getTable()->addUnique($copiedUnique);
}
// add the Behaviors of the parent table
foreach ($parentTable->getBehaviors() as $behavior) {
if ($behavior->getName() == 'concrete_inheritance_parent' || $behavior->getName() == 'concrete_inheritance') {
continue;
}
$copiedBehavior = clone $behavior;
$copiedBehavior->setTableModified(false);
$this->getTable()->addBehavior($copiedBehavior);
}
}