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


PHP Column::getReferrers方法代码示例

本文整理汇总了PHP中Propel\Generator\Model\Column::getReferrers方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::getReferrers方法的具体用法?PHP Column::getReferrers怎么用?PHP Column::getReferrers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Generator\Model\Column的用法示例。


在下文中一共展示了Column::getReferrers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addMutatorCloseBody

 /**
  * Adds the body of the close part of a mutator.
  *
  * @param string &$script
  * @param Column $column
  */
 protected function addMutatorCloseBody(&$script, Column $column)
 {
     $table = $this->getTable();
     if ($column->isForeignKey()) {
         foreach ($column->getForeignKeys() as $fk) {
             $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
             $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($column->getName()));
             if (!$colFK) {
                 continue;
             }
             $varName = $this->getFKVarName($fk);
             $script .= "\n        if (\$this->{$varName} !== null && \$this->" . $varName . "->get" . $colFK->getPhpName() . "() !== \$v) {\n            \$this->{$varName} = null;\n        }\n";
         }
         // foreach fk
     }
     /* if col is foreign key */
     foreach ($column->getReferrers() as $refFK) {
         $tblFK = $this->getDatabase()->getTable($refFK->getForeignTableName());
         if ($tblFK->getName() != $table->getName()) {
             foreach ($column->getForeignKeys() as $fk) {
                 $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
                 $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($column->getName()));
                 if ($refFK->isLocalPrimaryKey()) {
                     $varName = $this->getPKRefFKVarName($refFK);
                     $script .= "\n        // update associated " . $tblFK->getPhpName() . "\n        if (\$this->{$varName} !== null) {\n            \$this->{$varName}->set" . $colFK->getPhpName() . "(\$v);\n        }\n";
                 } else {
                     $collName = $this->getRefFKCollVarName($refFK);
                     $script .= "\n\n        // update associated " . $tblFK->getPhpName() . "\n        if (\$this->{$collName} !== null) {\n            foreach (\$this->{$collName} as \$referrerObject) {\n                    \$referrerObject->set" . $colFK->getPhpName() . "(\$v);\n                }\n            }\n";
                 }
                 // if (isLocalPrimaryKey
             }
             // foreach col->getPrimaryKeys()
         }
         // if tablFk != table
     }
     // foreach
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:43,代码来源:ObjectBuilder.php

示例2: testClearForeignKeys

 public function testClearForeignKeys()
 {
     $fks = array($this->getMock('Propel\\Generator\\Model\\ForeignKey'), $this->getMock('Propel\\Generator\\Model\\ForeignKey'));
     $table = $this->getTableMock('books');
     $table->expects($this->any())->method('getColumnForeignKeys')->with('author_id')->will($this->returnValue($fks));
     $column = new Column('author_id');
     $column->setTable($table);
     $column->addReferrer($fks[0]);
     $column->addReferrer($fks[1]);
     $this->assertTrue($column->isForeignKey());
     $this->assertTrue($column->hasMultipleFK());
     $this->assertTrue($column->hasReferrers());
     $this->assertTrue($column->hasReferrer($fks[0]));
     $this->assertCount(2, $column->getReferrers());
     // Clone the current column
     $clone = clone $column;
     $column->clearReferrers();
     $this->assertCount(0, $column->getReferrers());
     $this->assertCount(0, $clone->getReferrers());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:20,代码来源:ColumnTest.php


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