本文整理汇总了PHP中Propel\Generator\Model\Index::isUnique方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::isUnique方法的具体用法?PHP Index::isUnique怎么用?PHP Index::isUnique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Index
的用法示例。
在下文中一共展示了Index::isUnique方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateNamedIndex
public function testCreateNamedIndex()
{
$index = new Index('foo_idx');
$index->setTable($this->getTableMock('db_books'));
$this->assertEquals('foo_idx', $index->getName());
$this->assertFalse($index->isUnique());
$this->assertInstanceOf('Propel\\Generator\\Model\\Table', $index->getTable());
$this->assertSame('db_books', $index->getTableName());
$this->assertCount(0, $index->getColumns());
$this->assertFalse($index->hasColumns());
}
示例2: computeDiff
/**
* Computes the difference between two index objects.
*
* @param Index $fromIndex
* @param Index $toIndex
* @param boolean $caseInsensitive
* @return boolean
*/
public static function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false)
{
// Check for removed index columns in $toIndex
$fromIndexColumns = $fromIndex->getColumns();
$max = count($fromIndexColumns);
for ($i = 0; $i < $max; $i++) {
$indexColumn = $fromIndexColumns[$i];
if (!$toIndex->hasColumnAtPosition($i, $indexColumn, $fromIndex->getColumnSize($indexColumn), $caseInsensitive)) {
return true;
}
}
// Check for new index columns in $toIndex
$toIndexColumns = $toIndex->getColumns();
$max = count($toIndexColumns);
for ($i = 0; $i < $max; $i++) {
$indexColumn = $toIndexColumns[$i];
if (!$fromIndex->hasColumnAtPosition($i, $indexColumn, $toIndex->getColumnSize($indexColumn), $caseInsensitive)) {
return true;
}
}
// Check for difference in unicity
return $fromIndex->isUnique() !== $toIndex->isUnique();
}
示例3: getIndexType
protected function getIndexType(Index $index)
{
$type = '';
$vendorInfo = $index->getVendorInfoForType($this->getDatabaseType());
if ($vendorInfo && $vendorInfo->getParameter('Index_type')) {
$type = $vendorInfo->getParameter('Index_type') . ' ';
} elseif ($index->isUnique()) {
$type = 'UNIQUE ';
}
return $type;
}
示例4: 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 = "\nCREATE %sINDEX %s ON %s (%s)%s;\n";
return sprintf($pattern, $index->isUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()), $this->getColumnListDDL($index->getColumnObjects()), $this->generateBlockStorage($index));
}
示例5: 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->isUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->getColumnListDDL($index->getColumnObjects()));
}