本文整理汇总了PHP中ForeignKey::getLocalPrimaryKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::getLocalPrimaryKeys方法的具体用法?PHP ForeignKey::getLocalPrimaryKeys怎么用?PHP ForeignKey::getLocalPrimaryKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::getLocalPrimaryKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAtLeastOneLocalPrimaryKeyNotCovered
/**
* Returns true if at least one of the local columns of $fk is not already covered by another
* foreignKey in our collection (getCrossForeignKeys)
*
* E.g.
*
* table (local primary keys -> foreignKey):
*
* pk1 -> FK1
* pk2
* \
* -> FK2
* /
* pk3 -> FK3
* \
* -> FK4
* /
* pk4
*
* => FK1(pk1), FK2(pk2, pk3), FK3(pk3), FK4(pk3, pk4).
*
* isAtLeastOneLocalPrimaryKeyNotCovered(FK1) where none fks in our collection: true
* isAtLeastOneLocalPrimaryKeyNotCovered(FK2) where FK1 is in our collection: true
* isAtLeastOneLocalPrimaryKeyNotCovered(FK3) where FK1,FK2 is in our collection: false
* isAtLeastOneLocalPrimaryKeyNotCovered(FK4) where FK1,FK2 is in our collection: true
*
* @param ForeignKey $fk
* @return bool
*/
public function isAtLeastOneLocalPrimaryKeyNotCovered(ForeignKey $fk)
{
$primaryKeys = $fk->getLocalPrimaryKeys();
foreach ($primaryKeys as $primaryKey) {
$covered = false;
foreach ($this->getCrossForeignKeys() as $crossFK) {
if ($crossFK->hasLocalColumn($primaryKey)) {
$covered = true;
break;
}
}
//at least one is not covered, so return true
if (!$covered) {
return true;
}
}
return false;
}