本文整理汇总了PHP中Doctrine\DBAL\Schema\Index::isPrimary方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::isPrimary方法的具体用法?PHP Index::isPrimary怎么用?PHP Index::isPrimary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\Index
的用法示例。
在下文中一共展示了Index::isPrimary方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAdvancedIndexOptionsSQL
/**
* {@inheritdoc}
*/
protected function getAdvancedIndexOptionsSQL(Index $index)
{
if ($index->hasFlag('with_nulls_distinct') && $index->hasFlag('with_nulls_not_distinct')) {
throw new UnexpectedValueException('An Index can either have a "with_nulls_distinct" or "with_nulls_not_distinct" flag but not both.');
}
if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) {
return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
}
return parent::getAdvancedIndexOptionsSQL($index);
}
示例2: populatePrimaryKey
/**
* Populates a primary key based on a index.
*
* @param Attrs $attrs
* @param Index $index
*/
private function populatePrimaryKey($attrs, $index)
{
if (!$index->isPrimary()) {
return;
}
$columns = $index->getColumns();
$key = current($columns);
// We don't support composite primary keys quite yet.
if (count($columns) > 1) {
return;
}
$attrs->set($this->deriveName($key), ['key' => $key, 'type' => 'primary']);
}
示例3: indexToArray
/**
* @param string $table
* @param \Doctrine\DBAL\Schema\Index $index
* @return array
*/
protected function indexToArray($table, $index)
{
if ($index->isPrimary()) {
$type = 'primary';
} elseif ($index->isUnique()) {
$type = 'unique';
} else {
$type = 'index';
}
$array = ['type' => $type, 'name' => null, 'columns' => $index->getColumns()];
if (!$this->isDefaultIndexName($table, $index->getName(), $type, $index->getColumns())) {
$array['name'] = $index->getName();
}
return $array;
}
示例4: indexToArray
/**
* @param string $table
* @param \Doctrine\DBAL\Schema\Index $index
* @return array
*/
protected function indexToArray($table, $index)
{
if ($index->isPrimary()) {
$type = 'primary';
} elseif ($index->isUnique()) {
$type = 'unique';
} else {
$type = 'index';
}
$array = ['type' => $type, 'name' => null, 'columns' => $index->getColumns()];
if (!$this->ignoreIndexNames and !$this->isDefaultIndexName($table, $index->getName(), $type, $index->getColumns())) {
// Sent Index name to exclude spaces
$array['name'] = str_replace(' ', '', $index->getName());
}
return $array;
}
示例5: getSql
public function getSql(Index $index, $table)
{
if ($table instanceof Table) {
$table = $table->getQuotedName($this->platform);
}
$name = $index->getQuotedName($this->platform);
$columns = $index->getQuotedColumns($this->platform);
if (count($columns) == 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
if ($index->isPrimary()) {
return $this->platform->getCreatePrimaryKeySQL($index, $table);
}
$query = 'CREATE INDEX ' . $name . ' ON ' . $table;
$query .= ' USING gist(' . $this->platform->getIndexFieldDeclarationListSQL($columns) . ')';
return $query;
}
示例6: getAdvancedIndexOptionsSQL
/**
* Return the INDEX query section dealing with non-standard
* SQL Anywhere options.
*
* @param Index $index Index definition
*
* @return string
*/
protected function getAdvancedIndexOptionsSQL(Index $index)
{
$sql = '';
if (!$index->isPrimary() && $index->hasFlag('for_olap_workload')) {
$sql .= ' FOR OLAP WORKLOAD';
}
return $sql;
}
示例7: _addIndex
/**
* Add index to table
*
* @param Index $indexCandidate
* @return Table
*/
protected function _addIndex(Index $indexCandidate)
{
// check for duplicates
foreach ($this->_indexes as $existingIndex) {
if ($indexCandidate->isFullfilledBy($existingIndex)) {
return $this;
}
}
$indexName = $indexCandidate->getName();
$indexName = strtolower($indexName);
if (isset($this->_indexes[$indexName]) || $this->_primaryKeyName != false && $indexCandidate->isPrimary()) {
throw SchemaException::indexAlreadyExists($indexName, $this->_name);
}
// remove overruled indexes
foreach ($this->_indexes as $idxKey => $existingIndex) {
if ($indexCandidate->overrules($existingIndex)) {
unset($this->_indexes[$idxKey]);
}
}
if ($indexCandidate->isPrimary()) {
$this->_primaryKeyName = $indexName;
}
$this->_indexes[$indexName] = $indexCandidate;
return $this;
}
示例8: overrules
/**
* Detect if the other index is a non-unique, non primary index that can be overwritten by this one.
*
* @param Index $other
* @return bool
*/
public function overrules(Index $other)
{
if ($other->isPrimary()) {
return false;
} else {
if ($this->isSimpleIndex() && $other->isUnique()) {
return false;
}
}
if ($this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique())) {
return true;
}
return false;
}
示例9: getCreateIndexSQL
/**
* Gets the SQL to create an index on a table on this platform.
*
* @param Index $index
* @param string|Table $table name of the table on which the index is to be created
* @return string
*/
public function getCreateIndexSQL(Index $index, $table)
{
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
}
$name = $index->getQuotedName($this);
$columns = $index->getColumns();
if (count($columns) == 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
if ($index->isPrimary()) {
return $this->getCreatePrimaryKeySQL($index, $table);
} else {
$type = '';
if ($index->isUnique()) {
$type = 'UNIQUE ';
}
$query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table;
$query .= ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';
}
return $query;
}
示例10: getAdvancedIndexOptionsSQL
/**
* {@inheritdoc}
*/
protected function getAdvancedIndexOptionsSQL(Index $index)
{
if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) {
return ' WITH NULLS NOT DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
}
return parent::getAdvancedIndexOptionsSQL($index);
}
示例11: getPreAlterTableAlterPrimaryKeySQL
/**
* @param TableDiff $diff
* @param Index $index
*
* @return string[]
*/
private function getPreAlterTableAlterPrimaryKeySQL(TableDiff $diff, Index $index)
{
$sql = array();
if (!$index->isPrimary() || !$diff->fromTable instanceof Table) {
return $sql;
}
$tableName = $diff->getName($this)->getQuotedName($this);
// Dropping primary keys requires to unset autoincrement attribute on the particular column first.
foreach ($index->getColumns() as $columnName) {
$column = $diff->fromTable->getColumn($columnName);
if ($column->getAutoincrement() === true) {
$column->setAutoincrement(false);
$sql[] = 'ALTER TABLE ' . $tableName . ' MODIFY ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
// original autoincrement information might be needed later on by other parts of the table alteration
$column->setAutoincrement(true);
}
}
return $sql;
}
示例12: saveIndex
/**
* @param Index $index
* @param \SimpleXMLElement $xml
*/
private static function saveIndex($index, $xml)
{
$xml->addChild('name', $index->getName());
if ($index->isPrimary()) {
$xml->addChild('primary', 'true');
} elseif ($index->isUnique()) {
$xml->addChild('unique', 'true');
}
foreach ($index->getColumns() as $column) {
$field = $xml->addChild('field');
$field->addChild('name', $column);
$field->addChild('sorting', 'ascending');
}
}
示例13: createIndexReplacement
/**
* Creates a index replacement, which has quoted names.
*
* @param Index $index
*
* @return Index
*/
private function createIndexReplacement(Index $index)
{
return new Index($this->platform->quoteIdentifier($index->getName()), $this->quoteIdentifiers($index->getColumns()), $index->isUnique(), $index->isPrimary(), $index->getFlags(), $index->getOptions());
}
示例14: acceptIndex
/**
* Accept an index on in a table
*
* @param Table $table a table object
* @param Index $index a column object
*
* @return void
*/
public function acceptIndex(Table $table, Index $index)
{
$this->schemaArray['tables'][$table->getName()]['indexes'][$index->getName()] = array('name' => $index->getName(), 'columns' => $index->getColumns(), 'unique' => $index->isUnique(), 'primary' => $index->isPrimary());
}