• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Schema\Index类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getIndexDeclarationSQL

 /**
  * Obtain DBMS specific SQL code portion needed to set an index
  * declaration to be used in statements like CREATE TABLE.
  *
  * @param string $name          name of the index
  * @param Index $index          index definition
  * @return string               DBMS specific SQL code portion needed to set an index
  */
 public function getIndexDeclarationSQL($name, Index $index)
 {
     $type = '';
     if ($index->isUnique()) {
         $type = 'UNIQUE ';
     }
     if (count($index->getColumns()) == 0) {
         throw \InvalidArgumentException("Incomplete definition. 'columns' required.");
     }
     return $type . 'INDEX ' . $name . ' (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')';
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:19,代码来源:AbstractPlatform.php


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


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


示例19: getCreatePrimaryKeySQL

 public function getCreatePrimaryKeySQL(Index $index, $table)
 {
     if ($table instanceof Table) {
         $table = $table->getQuotedName($this);
     }
     return 'ALTER TABLE ' . $this->espoQuote($table) . ' ADD PRIMARY KEY (' . $this->getIndexFieldDeclarationListSQL($index->getQuotedColumns($this)) . ')';
 }
开发者ID:disearth,项目名称:espocrm,代码行数:7,代码来源:MySqlPlatform.php


示例20: checkIndex

 /**
  * @param Table     $table
  * @param Index     $index
  * @param Migration $migration
  *
  * @throws InvalidNameException
  */
 protected function checkIndex(Table $table, Index $index, Migration $migration)
 {
     $columns = $index->getColumns();
     foreach ($columns as $columnName) {
         if ($table->getColumn($columnName)->getLength() > MySqlPlatform::LENGTH_LIMIT_TINYTEXT) {
             throw new InvalidNameException(sprintf('Could not create index for column with length more than %s. ' . 'Please correct "%s" column length "%s" in table in "%s" migration', MySqlPlatform::LENGTH_LIMIT_TINYTEXT, $columnName, $table->getName(), get_class($migration)));
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:16,代码来源:MigrationExecutor.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Schema\Schema类代码示例发布时间:2022-05-23
下一篇:
PHP Schema\Identifier类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap