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


PHP Table::addIndex方法代码示例

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


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

示例1: createTable

 private function createTable(string $tableName) : Table
 {
     $table = new Table($tableName);
     $table->addColumn('aggregate_id', 'guid', ['notnull' => true]);
     $table->addColumn('occurred_on', 'datetime', ['notnull' => true]);
     $table->addColumn('name', 'string', ['notnull' => true]);
     $table->addColumn('event_class', 'string', ['notnull' => true]);
     $table->addColumn('event', 'text');
     $table->addIndex(['aggregate_id']);
     $table->addIndex(['occurred_on']);
     return $table;
 }
开发者ID:cocoders,项目名称:event-store-dbal-adapter,代码行数:12,代码来源:SchemaManager.php

示例2: makeTableRepresentation

 public function makeTableRepresentation(DBAL\Schema\Table $table)
 {
     $table->addColumn('id', 'string', ['length' => 100]);
     $table->addColumn('raw', 'string', ['length' => $this->length]);
     $table->addColumn('scheme', 'string', ['length' => 30]);
     $table->addColumn('domain', 'string', ['length' => 50]);
     $table->addColumn('port', 'integer', ['length' => 10]);
     $table->addColumn('path', 'string', ['length' => 200]);
     $table->addColumn('fragment', 'string', ['length' => 100]);
     $table->addColumn('last_indexed', 'integer', ['length' => 50]);
     $table->addIndex(['id', 'raw']);
     $table->addIndex(['id', 'domain']);
 }
开发者ID:taproot,项目名称:librarian,代码行数:13,代码来源:UrlIndex.php

示例3: fulltext

 /**
  * Adds a fulltext index to the table
  *
  * @param   array   $fields  fields
  * @param   string  $name    index name
  * @return  $this
  */
 public function fulltext($fields, $name)
 {
     $this->table->addIndex((array) $fields, $name);
     $index = $this->table->getIndex($name);
     $index->addFlag('fulltext');
     return $this;
 }
开发者ID:DoctorSanchez,项目名称:database,代码行数:14,代码来源:Table.php

示例4: makeTableRepresentation

 public function makeTableRepresentation(DBAL\Schema\Table $table)
 {
     $table->addColumn('id', 'string', ['length' => 100]);
     $table->addColumn('content', 'string', ['length' => $this->length]);
     $table->addColumn('last_indexed', 'integer', ['length' => 50]);
     $table->addIndex(['id', 'content']);
 }
开发者ID:taproot,项目名称:librarian,代码行数:7,代码来源:StringIndex.php

示例5: map

 /**
  * @param string          $schema
  * @param Table           $table
  * @param string          $name
  * @param FieldDefinition $definition
  */
 public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
 {
     $table->addColumn($name, 'float', ['notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'unique' => $definition->options()['unique'] ?? false]);
     if ($definition->options()['index'] ?? false) {
         $table->addIndex([$name]);
     }
 }
开发者ID:dumplie,项目名称:dumplie,代码行数:13,代码来源:FloatMapping.php

示例6: makeTableRepresentation

 public function makeTableRepresentation(DBAL\Schema\Table $table)
 {
     $table->addColumn('id', 'string', ['length' => 100]);
     $table->addColumn('datetime', 'datetime');
     $table->addColumn('last_indexed', 'integer', ['length' => 50]);
     $table->addIndex(['id', 'datetime']);
 }
开发者ID:taproot,项目名称:librarian,代码行数:7,代码来源:DateTimeIndex.php

示例7: acceptForeignKey

 /**
  * @param Table $localTable
  * @param ForeignKeyConstraint $fkConstraint
  */
 public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
 {
     if ($this->_addExplicitIndexForForeignKey) {
         $columns = $fkConstraint->getColumns();
         if ($localTable->columnsAreIndexed($columns)) {
             return;
         }
         $localTable->addIndex($columns);
     }
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:14,代码来源:FixSchema.php

示例8: addIndexes

 /**
  * Adds the missing indexes to the table
  *
  * @param \Doctrine\DBAL\Schema\Table $table Table object
  * @return \Doctrine\DBAL\Schema\Table Updated table object
  */
 protected function addIndexes(\Doctrine\DBAL\Schema\Table $table)
 {
     $indexes = array('idx_msord_sid_cdate' => array('siteid', 'cdate'), 'idx_msord_sid_cmonth' => array('siteid', 'cmonth'), 'idx_msord_sid_cweek' => array('siteid', 'cweek'), 'idx_msord_sid_hour' => array('siteid', 'chour'));
     foreach ($indexes as $name => $def) {
         if ($table->hasIndex($name) === false) {
             $table->addIndex($def, $name);
         }
     }
     return $table;
 }
开发者ID:nos3,项目名称:aimeos-core,代码行数:16,代码来源:OrderAddTimes.php

示例9: addIndexes

 /**
  * Adds the missing indexes to the table
  *
  * @param \Doctrine\DBAL\Schema\Table $table Table object
  * @return \Doctrine\DBAL\Schema\Table Updated table object
  */
 protected function addIndexes(\Doctrine\DBAL\Schema\Table $table)
 {
     $indexes = array('idx_ezpus_langid' => array('langid'), 'idx_ezpus_status_ln_fn' => array('status', 'lastname', 'firstname'), 'idx_ezpus_status_ad1_ad2' => array('status', 'address1', 'address2'), 'idx_ezpus_status_postal_city' => array('status', 'postal', 'city'), 'idx_ezpus_lastname' => array('lastname'), 'idx_ezpus_address1' => array('address1'), 'idx_ezpus_postal' => array('postal'), 'idx_ezpus_city' => array('city'));
     foreach ($indexes as $name => $def) {
         if ($table->hasIndex($name) === false) {
             $table->addIndex($def, $name);
         }
     }
     return $table;
 }
开发者ID:aimeos,项目名称:ai-ezpublish,代码行数:16,代码来源:EzuserAddAddress.php

示例10: testEncodedIndexNameIsTheSameAsDoctrineDefault

 public function testEncodedIndexNameIsTheSameAsDoctrineDefault()
 {
     $tableName = 'tbl123456789012345';
     $columnName = 'clmn1234567890';
     $table = new Table($tableName, [new Column($columnName, Type::getType('string'))]);
     $table->addIndex([$columnName]);
     $indices = $table->getIndexes();
     $doctrineResult = array_pop($indices)->getName();
     $generator = new DbIdentifierNameGenerator();
     $result = $generator->generateIndexName($tableName, [$columnName]);
     $this->assertEquals($doctrineResult, $result);
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:DbIdentifierNameGeneratorTest.php

示例11: testAlterTableAddPrimaryKey

 /**
  * @group DBAL-400
  */
 public function testAlterTableAddPrimaryKey()
 {
     $table = new Table('alter_table_add_pk');
     $table->addColumn('id', 'integer');
     $table->addColumn('foo', 'integer');
     $table->addIndex(array('id'), 'idx_id');
     $this->_sm->createTable($table);
     $comparator = new Comparator();
     $diffTable = clone $table;
     $diffTable->dropIndex('idx_id');
     $diffTable->setPrimaryKey(array('id'));
     $this->_sm->alterTable($comparator->diffTable($table, $diffTable));
     $table = $this->_sm->listTableDetails("alter_table_add_pk");
     $this->assertFalse($table->hasIndex('idx_id'));
     $this->assertTrue($table->hasPrimaryKey());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:19,代码来源:MySqlSchemaManagerTest.php

示例12: initialize

 public function initialize(array $options = [])
 {
     $tableName = $this->options[self::OPTION_TABLENAME];
     if (!method_exists($this->connection, 'getSchemaManager')) {
         throw new \RuntimeException('The provided connection does not support query building, please choose a different connection type ' . 'that does');
     }
     if ($this->connection->getSchemaManager()->tablesExist([$tableName])) {
         return;
     }
     $table = new Table($tableName);
     $table->addColumn('id', Type::STRING, ['length' => '36']);
     $table->addColumn('stream_id', Type::STRING, ['length' => '36']);
     $table->addColumn('sequence', Type::BIGINT);
     $table->addColumn('payload', Type::TEXT);
     $table->addColumn('emitted_at', Type::DATETIME);
     $table->setPrimaryKey(['id']);
     $table->addIndex(['stream_id']);
     $table->addUniqueIndex(['stream_id', 'sequence']);
     $this->connection->getSchemaManager()->createTable($table);
 }
开发者ID:phpinpractice,项目名称:event-store,代码行数:20,代码来源:Doctrine.php

示例13: testDropIndex

 /**
  * @group DBAL-224
  */
 public function testDropIndex()
 {
     $table = new Table("test");
     $table->addColumn('id', 'integer');
     $table->addIndex(array('id'), 'idx');
     $this->assertTrue($table->hasIndex('idx'));
     $table->dropIndex('idx');
     $this->assertFalse($table->hasIndex('idx'));
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:TableTest.php

示例14: buildIndex

 /**
  * @param string $columnName
  * @param array $options
  * @param string $className
  * @param Table $table
  */
 protected function buildIndex($columnName, $options, $className, $table)
 {
     $columnType = $this->fieldTypeHelper->getUnderlyingType($options[ExtendOptionsManager::TYPE_OPTION]);
     if ($this->fieldTypeHelper->isRelation($columnType) || in_array($columnType, [Type::TEXT])) {
         return;
     }
     $indexName = $this->nameGenerator->generateIndexNameForExtendFieldVisibleInGrid($className, $columnName);
     if ($this->isEnabled($options) && $this->isExtended($options) && !$table->hasIndex($indexName)) {
         $table->addIndex([$columnName], $indexName);
     } elseif (!$this->isEnabled($options) && $table->hasIndex($indexName)) {
         $table->dropIndex($indexName);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:UpdateExtendIndicesMigration.php

示例15: testAlterTableAddPrimaryKey

 /**
  * @group DBAL-400
  */
 public function testAlterTableAddPrimaryKey()
 {
     $table = new Table('alter_table_add_pk');
     $table->addColumn('id', 'integer');
     $table->addColumn('foo', 'integer');
     $table->addIndex(array('id'), 'idx_id');
     $comparator = new Comparator();
     $diffTable = clone $table;
     $diffTable->dropIndex('idx_id');
     $diffTable->setPrimaryKey(array('id'));
     $this->assertEquals(array('DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'), $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:15,代码来源:MySqlPlatformTest.php


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