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