當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。