本文整理汇总了PHP中ForeignKey::setDefaultJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::setDefaultJoin方法的具体用法?PHP ForeignKey::setDefaultJoin怎么用?PHP ForeignKey::setDefaultJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::setDefaultJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relateI18nTableToMainTable
protected function relateI18nTableToMainTable()
{
$table = $this->getTable();
$i18nTable = $this->i18nTable;
$pks = $this->getTable()->getPrimaryKey();
if (count($pks) > 1) {
throw new EngineException('The i18n behavior does not support tables with composite primary keys');
}
foreach ($pks as $column) {
if (!$i18nTable->hasColumn($column->getName())) {
$column = clone $column;
$column->setAutoIncrement(false);
$i18nTable->addColumn($column);
}
}
if (in_array($table->getName(), $i18nTable->getForeignTableNames())) {
return;
}
$fk = new ForeignKey();
$fk->setForeignTableCommonName($table->getCommonName());
$fk->setForeignSchemaName($table->getSchema());
$fk->setDefaultJoin('LEFT JOIN');
$fk->setOnDelete(ForeignKey::CASCADE);
$fk->setOnUpdate(ForeignKey::NONE);
foreach ($pks as $column) {
$fk->addReference($column->getName(), $column->getName());
}
$i18nTable->addForeignKey($fk);
}
示例2: relateDelegateToMainTable
protected function relateDelegateToMainTable($delegateTable, $mainTable)
{
$pks = $mainTable->getPrimaryKey();
foreach ($pks as $column) {
$mainColumnName = $column->getName();
if (!$delegateTable->hasColumn($mainColumnName)) {
$column = clone $column;
$column->setAutoIncrement(false);
$delegateTable->addColumn($column);
}
}
// Add a one-to-one fk
$fk = new ForeignKey();
$fk->setForeignTableCommonName($mainTable->getCommonName());
$fk->setForeignSchemaName($mainTable->getSchema());
$fk->setDefaultJoin('LEFT JOIN');
$fk->setOnDelete(ForeignKey::CASCADE);
$fk->setOnUpdate(ForeignKey::NONE);
foreach ($pks as $column) {
$fk->addReference($column->getName(), $column->getName());
}
$delegateTable->addForeignKey($fk);
}