本文整理匯總了PHP中Doctrine\DBAL\Schema\Table::hasForeignKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::hasForeignKey方法的具體用法?PHP Table::hasForeignKey怎麽用?PHP Table::hasForeignKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\DBAL\Schema\Table
的用法示例。
在下文中一共展示了Table::hasForeignKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreign
/**
* Assert that the table has a foreign key relationship.
*
* @param string $table
* @param string $column
* @param string $onUpdate
* @param string $onDelete
* @return $this
*/
public function foreign($table, $column = 'id', $onUpdate = 'cascade', $onDelete = 'cascade')
{
if (DB::connection() instanceof \Illuminate\Database\SQLiteConnection) {
$this->context->markTestIncomplete('Foreign keys cannot be tested with a SQLite database.');
return $this;
}
$name = $this->getIndexName('foreign');
$this->assertTrue($this->table->hasForeignKey($name), "The foreign key {$name} does not exist.");
$key = $this->table->getForeignKey($name);
$onUpdate && $this->context->assertEquals(strtoupper($onUpdate), $key->onUpdate());
$onDelete && $this->context->assertEquals(strtoupper($onDelete), $key->onDelete());
$this->context->assertEquals($table, $key->getForeignTableName());
$this->context->assertContains($column, $key->getForeignColumns());
return $this;
}
示例2: testNormalizesColumnNames
/**
* @dataProvider getNormalizesAssetNames
* @group DBAL-831
*/
public function testNormalizesColumnNames($assetName)
{
$table = new Table('test');
$table->addColumn($assetName, 'integer');
$table->addIndex(array($assetName), $assetName);
$table->addForeignKeyConstraint('test', array($assetName), array($assetName), array(), $assetName);
$this->assertTrue($table->hasColumn($assetName));
$this->assertTrue($table->hasColumn('foo'));
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Column', $table->getColumn($assetName));
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Column', $table->getColumn('foo'));
$this->assertTrue($table->hasIndex($assetName));
$this->assertTrue($table->hasIndex('foo'));
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $table->getIndex($assetName));
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $table->getIndex('foo'));
$this->assertTrue($table->hasForeignKey($assetName));
$this->assertTrue($table->hasForeignKey('foo'));
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $table->getForeignKey($assetName));
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $table->getForeignKey('foo'));
$table->renameIndex($assetName, $assetName);
$this->assertTrue($table->hasIndex($assetName));
$this->assertTrue($table->hasIndex('foo'));
$table->renameIndex($assetName, 'foo');
$this->assertTrue($table->hasIndex($assetName));
$this->assertTrue($table->hasIndex('foo'));
$table->renameIndex('foo', $assetName);
$this->assertTrue($table->hasIndex($assetName));
$this->assertTrue($table->hasIndex('foo'));
$table->renameIndex($assetName, 'bar');
$this->assertFalse($table->hasIndex($assetName));
$this->assertFalse($table->hasIndex('foo'));
$this->assertTrue($table->hasIndex('bar'));
$table->renameIndex('bar', $assetName);
$table->dropColumn($assetName);
$table->dropIndex($assetName);
$table->removeForeignKey($assetName);
$this->assertFalse($table->hasColumn($assetName));
$this->assertFalse($table->hasColumn('foo'));
$this->assertFalse($table->hasIndex($assetName));
$this->assertFalse($table->hasIndex('foo'));
$this->assertFalse($table->hasForeignKey($assetName));
$this->assertFalse($table->hasForeignKey('foo'));
}