本文整理汇总了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;
}
示例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']);
}
示例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;
}
示例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']);
}
示例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]);
}
}
示例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']);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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'));
}
示例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);
}
}
示例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)));
}