本文整理汇总了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
}
示例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());
}