PMA\libraries\Index::getFromTableByChoice PHP Метод

getFromTableByChoice() публичный статический Метод

Returns an array with all indexes from the given table of the requested types
public static getFromTableByChoice ( string $table, string $schema, integer $choices = 31 ) : Index[]
$table string table
$schema string schema
$choices integer choices
Результат Index[] array of indexes
    public static function getFromTableByChoice($table, $schema, $choices = 31)
    {
        $indexes = array();
        foreach (self::getFromTable($table, $schema) as $index) {
            if ($choices & Index::PRIMARY && $index->getChoice() == 'PRIMARY') {
                $indexes[] = $index;
            }
            if ($choices & Index::UNIQUE && $index->getChoice() == 'UNIQUE') {
                $indexes[] = $index;
            }
            if ($choices & Index::INDEX && $index->getChoice() == 'INDEX') {
                $indexes[] = $index;
            }
            if ($choices & Index::SPATIAL && $index->getChoice() == 'SPATIAL') {
                $indexes[] = $index;
            }
            if ($choices & Index::FULLTEXT && $index->getChoice() == 'FULLTEXT') {
                $indexes[] = $index;
            }
        }
        return $indexes;
    }

Usage Example

Пример #1
0
 /**
  * Get columns with indexes
  *
  * @param int $types types bitmask
  *
  * @return array an array of columns
  */
 function getColumnsWithIndex($types)
 {
     $columns_with_index = array();
     foreach (Index::getFromTableByChoice($this->_name, $this->_db_name, $types) as $index) {
         $columns = $index->getColumns();
         foreach ($columns as $column_name => $dummy) {
             $columns_with_index[] = $column_name;
         }
     }
     return $columns_with_index;
 }