本文整理汇总了PHP中Index::getColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::getColumns方法的具体用法?PHP Index::getColumns怎么用?PHP Index::getColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::getColumns方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isDuplicate
/**
* Check if given Index is duplicate of this
*
* @param Index $index Index
*
* @return bool TRUE if duplicate, otherwise FALSE
*/
public function isDuplicate(Index $index)
{
/**
* Check if columns are the same
*/
$duplicate = $this->getColumns() === $index->getColumns();
/**
* If indices have different unique status they cant be duplicates
*/
if ($this->isUnique() !== $index->isUnique()) {
$duplicate = false;
}
/**
* If one of the indicies is the primary key they cant be duplicates
*/
if ($this->isPrimaryKey() === true || $index->isPrimaryKey() === true) {
$duplicate = false;
}
return $duplicate;
}
示例2: 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;
}
示例3: getIndexColumnList
/**
* Creates a comma-separated list of column names for the index.
* For MySQL unique indexes there is the option of specifying size, so we cannot simply use
* the getColumnsList() method.
* @param Index $index
* @return string
*/
private function getIndexColumnList(Index $index)
{
$platform = $this->getPlatform();
$cols = $index->getColumns();
$list = array();
foreach ($cols as $col) {
$list[] = $this->quoteIdentifier($col) . ($index->hasColumnSize($col) ? '(' . $index->getColumnSize($col) . ')' : '');
}
return implode(', ', $list);
}
示例4: 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;
}
示例5: getIndexColumnListDDL
/**
* Creates a comma-separated list of column names for the index.
* For MySQL unique indexes there is the option of specifying size, so we cannot simply use
* the getColumnsList() method.
* @param Index $index
* @return string
*/
protected function getIndexColumnListDDL(Index $index)
{
$list = array();
foreach ($index->getColumns() as $col) {
$list[] = $this->quoteIdentifier($col) . ($index->hasColumnSize($col) ? '(' . $index->getColumnSize($col) . ')' : '');
}
return implode(', ', $list);
}
示例6: getAddIndexDDL
/**
* Builds the DDL SQL to add an Index.
*
* @param Index $index
* @return string
*/
public function getAddIndexDDL(Index $index)
{
// don't create index form primary key
if ($this->getPrimaryKeyName($index->getTable()) == $this->quoteIdentifier($index->getName())) {
return "";
}
$pattern = "\r\nCREATE %sINDEX %s ON %s (%s)%s;\r\n";
return sprintf($pattern, $index->getIsUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()), $this->getColumnListDDL($index->getColumns()), $this->generateBlockStorage($index));
}
示例7: getIndexDDL
/**
* Builds the DDL SQL for an Index object.
*
* @param Index $index
* @return string
*/
public function getIndexDDL(Index $index)
{
return sprintf('%sINDEX %s (%s)', $index->getIsUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->getColumnListDDL($index->getColumns()));
}