当前位置: 首页>>代码示例>>PHP>>正文


PHP Index::isPrimary方法代码示例

本文整理汇总了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);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:13,代码来源:SQLAnywhere16Platform.php

示例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']);
 }
开发者ID:drwrf,项目名称:mismatch-orm,代码行数:19,代码来源:Populator.php

示例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;
 }
开发者ID:19peaches,项目名称:laravel-generator,代码行数:20,代码来源:IndexParser.php

示例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;
 }
开发者ID:rohinigeeks,项目名称:laravel-sorcery,代码行数:21,代码来源:IndexGenerator.php

示例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;
 }
开发者ID:novikovsergey,项目名称:doctrine-postgis,代码行数:17,代码来源:SpatialIndexSqlGenerator.php

示例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;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:16,代码来源:SQLAnywherePlatform.php

示例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;
 }
开发者ID:michaelnavarro,项目名称:zc,代码行数:31,代码来源:Table.php

示例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;
 }
开发者ID:laiello,项目名称:masfletes,代码行数:20,代码来源:Index.php

示例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;
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:29,代码来源:AbstractPlatform.php

示例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);
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:10,代码来源:SQLAnywhere12Platform.php

示例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;
 }
开发者ID:doctrine,项目名称:dbal,代码行数:25,代码来源:MySqlPlatform.php

示例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');
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:18,代码来源:MDB2SchemaWriter.php

示例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());
 }
开发者ID:digilist,项目名称:snakedumper,代码行数:11,代码来源:IdentifierQuoter.php

示例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());
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:12,代码来源:ExportVisitor.php


注:本文中的Doctrine\DBAL\Schema\Index::isPrimary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。