本文整理汇总了PHP中Doctrine\DBAL\Schema\AbstractSchemaManager::listTableIndexes方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractSchemaManager::listTableIndexes方法的具体用法?PHP AbstractSchemaManager::listTableIndexes怎么用?PHP AbstractSchemaManager::listTableIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\AbstractSchemaManager
的用法示例。
在下文中一共展示了AbstractSchemaManager::listTableIndexes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDropAndCreateIndex
public function testDropAndCreateIndex()
{
$table = $this->getTestTable('test_create_index');
$table->addUniqueIndex(array('test'), 'test');
$this->_sm->dropAndCreateTable($table);
$this->_sm->dropAndCreateIndex($table->getIndex('test'), $table);
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
$this->assertType('array', $tableIndexes);
$this->assertEquals('test', strtolower($tableIndexes['test']->getName()));
$this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns()));
$this->assertTrue($tableIndexes['test']->isUnique());
$this->assertFalse($tableIndexes['test']->isPrimary());
}
示例2: getIndexes
/**
* Get table indexes.
*
* Get table indexes
* @param string $table
* @return array
*/
public function getIndexes($table)
{
$indexes = ['unique' => [], 'index' => []];
foreach ($this->schema->listTableIndexes($table) as $indexName => $index) {
if ('primary' != $indexName) {
$columns = $index->getColumns();
$unique = $index->isUnique();
$addKey = $unique ? 'unique' : 'index';
$isForeign = $this->isIndexForeign($columns, $table);
$generatedIndexName = $this->generateIndexName($table, $columns, $unique, $isForeign);
$columns = count($columns) == 1 ? reset($columns) : $columns;
if ($indexName == $generatedIndexName) {
$indexes[$addKey][] = $columns;
} else {
$indexes[$addKey][$indexName] = $columns;
}
}
}
return $indexes;
}
示例3: testListTableIndexes
public function testListTableIndexes()
{
$indexes = $this->sm->listTableIndexes('points');
$spatialIndexes = array('idx_27ba8e293be136c3', 'idx_27ba8e295f51a43c', 'idx_27ba8e295afbb72d', 'idx_27ba8e29b7a5f324', 'idx_27ba8e293c257075', 'idx_27ba8e2999674a3d', 'idx_27ba8e29cf3dedbb', 'idx_27ba8e29cf3dedbb', 'idx_27ba8e293d5fe69e', 'idx_27ba8e29b832b304');
$nonSpatialIndexes = array('idx_text', 'idx_text_gist');
foreach ($spatialIndexes as $spatialIndex) {
$this->assertArrayHasKey($spatialIndex, $indexes);
$this->assertTrue($indexes[$spatialIndex]->hasFlag('SPATIAL'));
}
foreach ($nonSpatialIndexes as $nonSpatialIndex) {
$this->assertArrayHasKey($nonSpatialIndex, $indexes);
$this->assertFalse($indexes[$nonSpatialIndex]->hasFlag('SPATIAL'));
}
}
示例4: __construct
/**
* @param string $table Table Name
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @param bool $ignoreIndexNames
*/
public function __construct($table, $schema)
{
$this->indexes = array();
$this->multiFieldIndexes = array();
$indexes = $schema->listTableIndexes($table);
foreach ($indexes as $index) {
$indexArray = $this->indexToArray($table, $index);
if (count($indexArray['columns']) == 1) {
$columnName = $indexArray['columns'][0];
$this->indexes[$columnName] = (object) $indexArray;
} else {
$this->multiFieldIndexes[] = (object) $indexArray;
}
}
}
示例5: checkPivots
/**
* return the the interesect on primary index and foreign key.
* if we have 2 primary key that are also foreign key without a type field it should be a pivot table !
*
* @param $table
* @return array
*/
public function checkPivots($table)
{
$foreignKeys = $this->schema->listTableForeignKeys($table);
$indexes = $this->schema->listTableIndexes($table);
$toto = [];
foreach ($foreignKeys as $key) {
$toto[] = $key->getLocalColumns();
}
$tata = [];
foreach ($indexes as $key) {
if ($key->isPrimary()) {
$tata[] = $key->getColumns();
}
}
return array_intersect(array_flatten($toto), array_flatten($tata));
}
示例6: testDoesNotListIndexesImplicitlyCreatedByForeignKeys
/**
* @group DBAL-1095
*/
public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys()
{
if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
}
$primaryTable = new Table('test_list_index_implicit_primary');
$primaryTable->addColumn('id', 'integer');
$primaryTable->setPrimaryKey(array('id'));
$foreignTable = new Table('test_list_index_implicit_foreign');
$foreignTable->addColumn('fk1', 'integer');
$foreignTable->addColumn('fk2', 'integer');
$foreignTable->addIndex(array('fk1'), 'explicit_fk1_idx');
$foreignTable->addForeignKeyConstraint('test_list_index_implicit_primary', array('fk1'), array('id'));
$foreignTable->addForeignKeyConstraint('test_list_index_implicit_primary', array('fk2'), array('id'));
$this->_sm->dropAndCreateTable($primaryTable);
$this->_sm->dropAndCreateTable($foreignTable);
$indexes = $this->_sm->listTableIndexes('test_list_index_implicit_foreign');
$this->assertCount(2, $indexes);
$this->assertArrayHasKey('explicit_fk1_idx', $indexes);
$this->assertArrayHasKey('idx_6d88c7b4fdc58d6c', $indexes);
}
示例7: listTableIndexes
/**
* {@see AbstractSchemaManager::listTableIndexes}
*/
public function listTableIndexes($table)
{
return $this->manager->listTableIndexes($this->replacePrefix($table));
}
示例8: listIndexes
/**
* @return array
*/
private function listIndexes()
{
return $this->schema->listTableIndexes($this->table);
}