当前位置: 首页>>代码示例>>PHP>>正文


PHP ForeignKey::setPhpName方法代码示例

本文整理汇总了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'));
     }
 }
开发者ID:smirik,项目名称:propel-taggable-behavior,代码行数:39,代码来源:TaggableBehavior.php


注:本文中的ForeignKey::setPhpName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。