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


PHP Schema\Index类代码示例

本文整理汇总了PHP中Doctrine\DBAL\Schema\Index的典型用法代码示例。如果您正苦于以下问题:PHP Index类的具体用法?PHP Index怎么用?PHP Index使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Index类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: getCreateSpatialIndexSQL

 /**
  * Generates the sql to create a spatial index.
  * 
  * @param SpatialIndex $index
  * @param Table | string $table
  * @return string The sql to create a spatial index on the database.
  * @throws \InvalidArgumentException
  */
 public function getCreateSpatialIndexSQL(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.");
     }
     $query = 'CREATE INDEX ' . $name . ' ON ' . $table;
     $query .= ' USING GIST (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';
     return $query;
 }
开发者ID:agnetsolutions,项目名称:dbal,代码行数:22,代码来源:PostGISPlatform.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getIndexDeclarationSQL

 /**
  * Obtains DBMS specific SQL code portion needed to set an index
  * declaration to be used in statements like CREATE TABLE.
  *
  * @param string                       $name  The name of the index.
  * @param \Doctrine\DBAL\Schema\Index  $index The index definition.
  *
  * @return string DBMS specific SQL code portion needed to set an index.
  *
  * @throws \InvalidArgumentException
  */
 public function getIndexDeclarationSQL($name, Index $index)
 {
     $columns = $index->getQuotedColumns($this);
     if (count($columns) === 0) {
         throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
     }
     return $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')' . $this->getPartialIndexSQL($index);
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:19,代码来源:AbstractPlatform.php

示例8: _appendUniqueConstraintDefinition

 /**
  * Extend unique key constraint with required filters
  *
  * @param string                      $sql
  * @param \Doctrine\DBAL\Schema\Index $index
  *
  * @return string
  */
 private function _appendUniqueConstraintDefinition($sql, Index $index)
 {
     $fields = array();
     foreach ($index->getQuotedColumns($this) as $field) {
         $fields[] = $field . ' IS NOT NULL';
     }
     return $sql . ' WHERE ' . implode(' AND ', $fields);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:16,代码来源:SQLServerPlatform.php

示例9: checkIndex

 /**
  * Do checks for indexes.
  *
  * @param Index         $index
  * @param IgnoredChange $ignoredChange
  *
  * @return boolean
  */
 protected function checkIndex(Index $index, IgnoredChange $ignoredChange)
 {
     // Not needed to be implemented yet
     if ($ignoredChange->getPropertyName() !== $index->getName()) {
         return false;
     }
     return false;
 }
开发者ID:zomars,项目名称:bolt,代码行数:16,代码来源:DiffUpdater.php

示例10: dropAndCreateIndex

 /**
  * Drops and creates a new index on a table.
  *
  * @param \Doctrine\DBAL\Schema\Index        $index
  * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the index is to be created.
  *
  * @return void
  */
 public function dropAndCreateIndex(Index $index, $table)
 {
     $this->tryMethod('dropIndex', $index->getQuotedName($this->_platform), $table);
     $this->createIndex($index, $table);
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:13,代码来源:AbstractSchemaManager.php

示例11: getCreateIndexSQLFlags

 /**
  * {@inheritdoc}
  */
 protected function getCreateIndexSQLFlags(Index $index)
 {
     $type = '';
     if ($index->hasFlag('virtual')) {
         $type .= 'VIRTUAL ';
     }
     if ($index->isUnique()) {
         $type .= 'UNIQUE ';
     }
     if ($index->hasFlag('clustered')) {
         $type .= 'CLUSTERED ';
     }
     return $type;
 }
开发者ID:kierkegaard13,项目名称:graph-generator,代码行数:17,代码来源:SQLAnywherePlatform.php

示例12: _addIndex

 /**
  * Adds an index to the table.
  *
  * @param Index $indexCandidate
  *
  * @return self
  *
  * @throws SchemaException
  */
 protected function _addIndex(Index $indexCandidate)
 {
     $indexName = $indexCandidate->getName();
     $indexName = $this->normalizeIdentifier($indexName);
     $replacedImplicitIndexes = array();
     foreach ($this->implicitIndexes as $name => $implicitIndex) {
         if ($implicitIndex->isFullfilledBy($indexCandidate) && isset($this->_indexes[$name])) {
             $replacedImplicitIndexes[] = $name;
         }
     }
     if (isset($this->_indexes[$indexName]) && !in_array($indexName, $replacedImplicitIndexes, true) || $this->_primaryKeyName != false && $indexCandidate->isPrimary()) {
         throw SchemaException::indexAlreadyExists($indexName, $this->_name);
     }
     foreach ($replacedImplicitIndexes as $name) {
         unset($this->_indexes[$name], $this->implicitIndexes[$name]);
     }
     if ($indexCandidate->isPrimary()) {
         $this->_primaryKeyName = $indexName;
     }
     $this->_indexes[$indexName] = $indexCandidate;
     return $this;
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:31,代码来源:Table.php

示例13: 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

示例14: getRenameIndexSQL

 /**
  * {@inheritdoc}
  */
 protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)
 {
     if (strpos($tableName, '.') !== false) {
         list($schema) = explode('.', $tableName);
         $oldIndexName = $schema . '.' . $oldIndexName;
     }
     return array('ALTER INDEX ' . $oldIndexName . ' RENAME TO ' . $index->getQuotedName($this));
 }
开发者ID:cuppyzh,项目名称:go_laundry,代码行数:11,代码来源:PostgreSqlPlatform.php

示例15: getCreateIndexSQLFlags

 /**
  * {@inheritDoc}
  */
 protected function getCreateIndexSQLFlags(Index $index)
 {
     $type = '';
     if ($index->isUnique()) {
         $type .= 'UNIQUE ';
     } elseif ($index->hasFlag('fulltext')) {
         $type .= 'FULLTEXT ';
     } elseif ($index->hasFlag('spatial')) {
         $type .= 'SPATIAL ';
     }
     return $type;
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:15,代码来源:MySqlPlatform.php


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