本文整理汇总了PHP中Propel\Generator\Model\ForeignKey::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::getTable方法的具体用法?PHP ForeignKey::getTable怎么用?PHP ForeignKey::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::getTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDropForeignKeyDDL
public function getDropForeignKeyDDL(ForeignKey $fk)
{
if (!$this->supportsForeignKeys($fk->getTable())) {
return '';
}
if ($fk->isSkipSql()) {
return;
}
$pattern = "\nALTER TABLE %s DROP FOREIGN KEY %s;\n";
return sprintf($pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->quoteIdentifier($fk->getName()));
}
示例2: getAddForeignKeyDDL
public function getAddForeignKeyDDL(ForeignKey $fk)
{
if ($fk->isSkipSql() || $fk->isPolymorphic()) {
return;
}
$pattern = "\nBEGIN\nALTER TABLE %s ADD %s\nEND\n;\n";
return sprintf($pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->getForeignKeyDDL($fk));
}
示例3: addRefFkScheduledForDeletionAttribute
protected function addRefFkScheduledForDeletionAttribute(&$script, ForeignKey $refFK)
{
$className = $this->getClassNameFromTable($refFK->getTable());
$fkName = lcfirst($this->getRefFKPhpNameAffix($refFK, true));
$script .= "\n /**\n * An array of objects scheduled for deletion.\n * @var ObjectCollection|{$className}[]\n */\n protected \${$fkName}ScheduledForDeletion = null;\n";
}
示例4: getRefRelatedBySuffix
protected static function getRefRelatedBySuffix(ForeignKey $fk)
{
$relCol = '';
foreach ($fk->getLocalForeignMapping() as $localColumnName => $foreignColumnName) {
$localTable = $fk->getTable();
$localColumn = $localTable->getColumn($localColumnName);
if (!$localColumn) {
throw new RuntimeException(sprintf('Could not fetch column: %s in table %s.', $localColumnName, $localTable->getName()));
}
$foreignKeysToForeignTable = $localTable->getForeignKeysReferencingTable($fk->getForeignTableName());
if ($fk->getForeignTableName() == $fk->getTableName()) {
// self referential foreign key
$relCol .= $fk->getForeignTable()->getColumn($foreignColumnName)->getPhpName();
if (count($foreignKeysToForeignTable) > 1) {
// several self-referential foreign keys
$relCol .= array_search($fk, $foreignKeysToForeignTable);
}
} elseif (count($foreignKeysToForeignTable) > 1 || count($fk->getForeignTable()->getForeignKeysReferencingTable($fk->getTableName())) > 0) {
// several foreign keys to the same table, or symmetrical foreign key in foreign table
$relCol .= $localColumn->getPhpName();
}
}
if (!empty($relCol)) {
$relCol = 'RelatedBy' . $relCol;
}
return $relCol;
}
示例5: getDropForeignKeyDDL
/**
* Builds the DDL SQL to drop a foreign key.
*
* @param ForeignKey $fk
* @return string
*/
public function getDropForeignKeyDDL(ForeignKey $fk)
{
if ($fk->isSkipSql() || $fk->isPolymorphic()) {
return;
}
$pattern = "\nALTER TABLE %s DROP CONSTRAINT %s;\n";
return sprintf($pattern, $this->quoteIdentifier($fk->getTable()->getName()), $this->quoteIdentifier($fk->getName()));
}
示例6: getReferrerVersionsColumn
public function getReferrerVersionsColumn(ForeignKey $fk)
{
$fkTableName = $fk->getTable()->getName();
$fkIdsColumnName = $fkTableName . '_versions';
return $this->versionTable->getColumn($fkIdsColumnName);
}
示例7: addCrossFKDoAdd
/**
* @param string &$script The script will be modified in this method.
* @param ForeignKey $refFK
* @param ForeignKey $crossFK
*/
protected function addCrossFKDoAdd(&$script, ForeignKey $refFK, ForeignKey $crossFK)
{
$relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false);
// lcfirst() doesn't exist in PHP < 5.3
$lowerRelatedObjectClassName = $relatedObjectClassName;
$lowerRelatedObjectClassName[0] = strtolower($lowerRelatedObjectClassName[0]);
$joinedTableObjectBuilder = $this->getNewObjectBuilder($refFK->getTable());
$className = $joinedTableObjectBuilder->getObjectClassname();
$tblFK = $refFK->getTable();
$foreignObjectName = '$' . $tblFK->getStudlyPhpName();
$script .= "\n /**\n * @param {$relatedObjectClassName} \${$lowerRelatedObjectClassName} The {$lowerRelatedObjectClassName} object to add.\n */\n protected function doAdd{$relatedObjectClassName}(\${$lowerRelatedObjectClassName})\n {\n {$foreignObjectName} = new {$className}();\n {$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});\n \$this->add{$className}({$foreignObjectName});\n }\n";
}
示例8: testSetTable
public function testSetTable()
{
$table = $this->getTableMock('book');
$table->expects($this->once())->method('getSchema')->will($this->returnValue('books'));
$fk = new ForeignKey();
$fk->setTable($table);
$this->assertInstanceOf('Propel\\Generator\\Model\\Table', $fk->getTable());
$this->assertSame('books', $fk->getSchemaName());
$this->assertSame('book', $fk->getTableName());
}
示例9: addCrossFKRemove
/**
* Adds the method that remove an object from the referrer fkey collection.
* @param string $script The script will be modified in this method.
* @param ForeignKey $refFK
* @param ForeignKey $crossFK
*/
protected function addCrossFKRemove(&$script, ForeignKey $refFK, ForeignKey $crossFK)
{
$relCol = $this->getFKPhpNameAffix($crossFK, $plural = true);
$collName = 'coll' . $relCol;
$tblFK = $refFK->getTable();
$joinedTableObjectBuilder = $this->getNewObjectBuilder($refFK->getTable());
$className = $joinedTableObjectBuilder->getObjectClassname();
$M2MScheduledForDeletion = lcfirst($relCol) . "ScheduledForDeletion";
$crossObjectName = '$' . $crossFK->getForeignTable()->getStudlyPhpName();
$crossObjectClassName = $this->getNewObjectBuilder($crossFK->getForeignTable())->getObjectClassname();
$relatedObjectClassName = $this->getFKPhpNameAffix($crossFK, $plural = false);
$script .= "\n /**\n * Remove a {$crossObjectClassName} object to this object\n * through the {$tblFK->getName()} cross reference table.\n *\n * @param {$crossObjectClassName} {$crossObjectName} The {$className} object to relate\n * @return " . $this->getObjectClassname() . " The current object (for fluent API support)\n */\n public function remove{$relatedObjectClassName}({$crossObjectClassName} {$crossObjectName})\n {\n if (\$this->get{$relCol}()->contains({$crossObjectName})) {\n \$this->{$collName}->remove(\$this->{$collName}->search({$crossObjectName}));\n\n if (null === \$this->{$M2MScheduledForDeletion}) {\n \$this->{$M2MScheduledForDeletion} = clone \$this->{$collName};\n \$this->{$M2MScheduledForDeletion}->clear();\n }\n\n \$this->{$M2MScheduledForDeletion}[] = {$crossObjectName};\n }\n\n return \$this;\n }\n";
}