本文整理匯總了PHP中Propel\Generator\Model\ForeignKey::setPhpName方法的典型用法代碼示例。如果您正苦於以下問題:PHP ForeignKey::setPhpName方法的具體用法?PHP ForeignKey::setPhpName怎麽用?PHP ForeignKey::setPhpName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Propel\Generator\Model\ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::setPhpName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addForeignKey
/**
* Adds a relation from logTable to origin table.
*
* @param Table $logTable
*/
protected function addForeignKey(Table $logTable)
{
$table = $this->getTable();
if ($table->getForeignKeysReferencingTable($table->getName())) {
//if already a foreignKey exist to origin table then don't add a second.
return;
}
// create the foreign key
$fk = new ForeignKey();
$fk->setForeignTableCommonName($table->getCommonName());
$fk->setForeignSchemaName($table->getSchema());
$fk->setPhpName('Origin');
$fk->setOnDelete('CASCADE');
$fk->setOnUpdate('CASCADE');
foreach ($table->getPrimaryKey() as $column) {
$fk->addReference($logTable->getColumn($column->getName()), $column);
}
$logTable->addForeignKey($fk);
}
示例2: ForeignKey
$fkCategoryPost->addReference('category_id', 'id');
$fkCategoryPost->setForeignTableCommonName('blog_category');
$fkCategoryPost->setRefPhpName('Posts');
$fkCategoryPost->setPhpName('Category');
$fkCategoryPost->setDefaultJoin('Criteria::INNER_JOIN');
$fkCategoryPost->setOnDelete('SETNULL');
$fkPostTag = new ForeignKey('fk_post_has_tags');
$fkPostTag->addReference('post_id', 'id');
$fkPostTag->setForeignTableCommonName('blog_post');
$fkPostTag->setPhpName('Post');
$fkPostTag->setDefaultJoin('Criteria::LEFT_JOIN');
$fkPostTag->setOnDelete('CASCADE');
$fkTagPost = new ForeignKey('fk_tag_has_posts');
$fkTagPost->addReference('tag_id', 'id');
$fkTagPost->setForeignTableCommonName('blog_tag');
$fkTagPost->setPhpName('Tag');
$fkTagPost->setDefaultJoin('Criteria::LEFT_JOIN');
$fkTagPost->setOnDelete('CASCADE');
/* Regular Indexes */
$pageContentFulltextIdx = new Index('page_content_fulltext_idx');
$pageContentFulltextIdx->setColumns([['name' => 'content']]);
$pageContentFulltextIdx->addVendorInfo(new VendorInfo('mysql', ['Index_type' => 'FULLTEXT']));
/* Unique Indexes */
$authorUsernameUnique = new Unique('author_password_unique_idx');
$authorUsernameUnique->setColumns([['name' => 'username', 'size' => '8']]);
/* Behaviors */
$timestampableBehavior = new TimestampableBehavior();
$timestampableBehavior->setName('timestampable');
$sluggableBehavior = new SluggableBehavior();
$sluggableBehavior->setName('sluggable');
/* Tables */
示例3: testSetNames
public function testSetNames()
{
$fk = new ForeignKey();
$fk->setName('book_author');
$fk->setPhpName('Author');
$fk->setRefPhpName('Books');
$this->assertSame('book_author', $fk->getName());
$this->assertSame('Author', $fk->getPhpName());
$this->assertSame('Books', $fk->getRefPhpName());
}