本文整理汇总了PHP中ForeignKey::setPhpName方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::setPhpName方法的具体用法?PHP ForeignKey::setPhpName怎么用?PHP ForeignKey::setPhpName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::setPhpName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTagTable
protected function createTagTable()
{
$table = $this->getTable();
$tagTableName = $this->getTagTableName();
$tagTablePhpName = $this->replaceTokens($this->parameters['tag_table_phpname']);
$database = $table->getDatabase();
if ($database->hasTable($tagTableName)) {
$this->tagTable = $database->getTable($tagTableName);
} else {
$this->tagTable = $database->addTable(array('name' => $tagTableName, 'phpName' => $tagTablePhpName, 'package' => $table->getPackage(), 'schema' => $table->getSchema(), 'namespace' => '\\' . $table->getNamespace()));
// every behavior adding a table should re-execute database behaviors
// see bug 2188 http://www.propelorm.org/changeset/2188
foreach ($database->getBehaviors() as $behavior) {
$behavior->modifyDatabase();
}
}
if (!$this->tagTable->hasColumn('id')) {
$this->tagTable->addColumn(array('name' => 'id', 'type' => PropelTypes::INTEGER, 'primaryKey' => 'true', 'autoIncrement' => 'true'));
}
if ($this->tagTable->hasColumn('category_id')) {
$categoryFkColumn = $this->tagTable->getColumn('category_id');
} else {
$categoryFkColumn = $this->tagTable->addColumn(array('name' => 'category_id', 'type' => PropelTypes::INTEGER, 'required' => false));
}
$fkTagCategory = new ForeignKey();
$fkTagCategory->setPhpName('Category');
$fkTagCategory->setForeignTableCommonName($this->tagCategoryTable->getCommonName());
$fkTagCategory->setForeignSchemaName($this->tagCategoryTable->getSchema());
$fkTagCategory->setOnDelete(ForeignKey::CASCADE);
$fkTagCategory->setOnUpdate(ForeignKey::CASCADE);
$pks = $this->getTable()->getPrimaryKey();
foreach ($pks as $column) {
$fkTagCategory->addReference($categoryFkColumn->getName(), $column->getName());
}
$this->tagTable->addForeignKey($fkTagCategory);
if (!$this->tagTable->hasColumn('name')) {
$this->tagTable->addColumn(array('name' => 'name', 'type' => PropelTypes::VARCHAR, 'size' => '60', 'primaryString' => 'true'));
}
}