本文整理汇总了PHP中Propel\Generator\Model\ForeignKey::setTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::setTable方法的具体用法?PHP ForeignKey::setTable怎么用?PHP ForeignKey::setTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::setTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addForeignKey
/**
* A utility function to create a new foreign key
* from attrib and add it to this table.
*/
public function addForeignKey($fkdata)
{
if ($fkdata instanceof ForeignKey) {
$fk = $fkdata;
$fk->setTable($this);
$this->foreignKeys[] = $fk;
if ($this->foreignTableNames === null) {
$this->foreignTableNames = array();
}
if (!in_array($fk->getForeignTableName(), $this->foreignTableNames)) {
$this->foreignTableNames[] = $fk->getForeignTableName();
}
return $fk;
} else {
$fk = new ForeignKey();
$fk->setTable($this);
$fk->loadFromXML($fkdata);
return $this->addForeignKey($fk);
}
}
示例2: addForeignKey
/**
* Adds a new foreign key to this table.
*
* @param ForeignKey|array $foreignKey The foreign key mapping
* @return ForeignKey
*/
public function addForeignKey($foreignKey)
{
if ($foreignKey instanceof ForeignKey) {
$fk = $foreignKey;
$fk->setTable($this);
$name = $fk->getPhpName() ?: $fk->getName();
if (isset($this->foreignKeysByName[$name])) {
throw new EngineException(sprintf('Foreign key "%s" declared twice in table "%s". Please specify a different php name!', $name, $this->getName()));
}
$this->foreignKeys[] = $fk;
$this->foreignKeysByName[$name] = $fk;
if (!in_array($fk->getForeignTableName(), $this->foreignTableNames)) {
$this->foreignTableNames[] = $fk->getForeignTableName();
}
return $fk;
}
$fk = new ForeignKey(isset($foreignKey['name']) ? $foreignKey['name'] : null);
$fk->setTable($this);
$fk->loadMapping($foreignKey);
return $this->addForeignKey($fk);
}
示例3: addForeignKey
/**
* Adds a new foreign key to this table.
*
* @param ForeignKey|array
* @return ForeignKey
*/
public function addForeignKey($fkdata)
{
if ($fkdata instanceof ForeignKey) {
$fk = $fkdata;
$fk->setTable($this);
$this->foreignKeys[] = $fk;
if (!in_array($fk->getForeignTableName(), $this->foreignTableNames)) {
$this->foreignTableNames[] = $fk->getForeignTableName();
}
return $fk;
}
$fk = new ForeignKey();
$fk->setTable($this);
$fk->loadMapping($fkdata);
return $this->addForeignKey($fk);
}
示例4: testToString
public function testToString()
{
$tableA = new Table('A');
$tableB = new Table('B');
$diff = new TableDiff($tableA, $tableB);
$diff->addAddedColumn('id', new Column('id', 'integer'));
$diff->addRemovedColumn('category_id', new Column('category_id', 'integer'));
$colFoo = new Column('foo', 'integer');
$colBar = new Column('bar', 'integer');
$tableA->addColumn($colFoo);
$tableA->addColumn($colBar);
$diff->addRenamedColumn($colFoo, $colBar);
$columnDiff = new ColumnDiff($colFoo, $colBar);
$diff->addModifiedColumn('foo', $columnDiff);
$fk = new ForeignKey('category');
$fk->setTable($tableA);
$fk->setForeignTableCommonName('B');
$fk->addReference('category_id', 'id');
$fkChanged = clone $fk;
$fkChanged->setForeignTableCommonName('C');
$fkChanged->addReference('bla', 'id2');
$fkChanged->setOnDelete('cascade');
$fkChanged->setOnUpdate('cascade');
$diff->addAddedFk('category', $fk);
$diff->addModifiedFk('category', $fk, $fkChanged);
$diff->addRemovedFk('category', $fk);
$index = new Index('test_index');
$index->setTable($tableA);
$index->setColumns([$colFoo]);
$indexChanged = clone $index;
$indexChanged->setColumns([$colBar]);
$diff->addAddedIndex('test_index', $index);
$diff->addModifiedIndex('test_index', $index, $indexChanged);
$diff->addRemovedIndex('test_index', $index);
$string = (string) $diff;
$expected = ' A:
addedColumns:
- id
removedColumns:
- category_id
modifiedColumns:
A.FOO:
modifiedProperties:
renamedColumns:
foo: bar
addedIndices:
- test_index
removedIndices:
- test_index
modifiedIndices:
- test_index
addedFks:
- category
removedFks:
- category
modifiedFks:
category:
localColumns: from ["category_id"] to ["category_id","bla"]
foreignColumns: from ["id"] to ["id","id2"]
onUpdate: from to CASCADE
onDelete: from to CASCADE
';
$this->assertEquals($expected, $string);
}
示例5: testSetTable
public function testSetTable()
{
$table = $this->getTableMock('book');
$table->expects($this->once())->method('getSchema')->will($this->returnValue('books'));
$fk = new ForeignKey();
$fk->setTable($table);
$this->assertInstanceOf('Propel\\Generator\\Model\\Table', $fk->getTable());
$this->assertSame('books', $fk->getSchemaName());
$this->assertSame('book', $fk->getTableName());
}