本文整理匯總了PHP中Index::hasColumnAtPosition方法的典型用法代碼示例。如果您正苦於以下問題:PHP Index::hasColumnAtPosition方法的具體用法?PHP Index::hasColumnAtPosition怎麽用?PHP Index::hasColumnAtPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Index
的用法示例。
在下文中一共展示了Index::hasColumnAtPosition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: computeDiff
/**
* Compute the difference between two index objects
*
* @param Index $fromIndex
* @param Index $toIndex
* @param boolean $caseInsensitive Whether the comparison is case insensitive.
* False by default.
*
* @return boolean false if the two indices are similar, true if they have differences
*/
public static function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false)
{
// Check for removed index columns in $toIndex
$fromIndexColumns = $fromIndex->getColumns();
for ($i = 0; $i < count($fromIndexColumns); $i++) {
$indexColumn = $fromIndexColumns[$i];
if (!$toIndex->hasColumnAtPosition($i, $indexColumn, null, $caseInsensitive)) {
return true;
}
}
// Check for new index columns in $toIndex
$toIndexColumns = $toIndex->getColumns();
for ($i = 0; $i < count($toIndexColumns); $i++) {
$indexColumn = $toIndexColumns[$i];
if (!$fromIndex->hasColumnAtPosition($i, $indexColumn, null, $caseInsensitive)) {
return true;
}
}
// Check for difference in unicity
if ($fromIndex->isUnique() != $toIndex->isUnique()) {
return true;
}
return false;
}
示例2: diffIndex
/**
* Finds the difference between the indexes $index1 and $index2.
*
* Compares $index1 with $index2 and returns $index2 if there are any
* differences or false in case there are no differences.
*
* @param Index $index1
* @param Index $index2
* @return bool
*/
public function diffIndex(Index $index1, Index $index2)
{
if ($index1->isPrimary() != $index2->isPrimary()) {
return true;
}
if ($index1->isUnique() != $index2->isUnique()) {
return true;
}
// Check for removed index fields in $index2
$index1Columns = $index1->getColumns();
for ($i = 0; $i < count($index1Columns); $i++) {
$indexColumn = $index1Columns[$i];
if (!$index2->hasColumnAtPosition($indexColumn, $i)) {
return true;
}
}
// Check for new index fields in $index2
$index2Columns = $index2->getColumns();
for ($i = 0; $i < count($index2Columns); $i++) {
$indexColumn = $index2Columns[$i];
if (!$index1->hasColumnAtPosition($indexColumn, $i)) {
return true;
}
}
return false;
}