PMA\libraries\Index::getFromTable PHP Method

getFromTable() public static method

returns an array with all indexes from the given table
public static getFromTable ( string $table, string $schema ) : Index[]
$table string table
$schema string schema
return Index[] array of indexes
    public static function getFromTable($table, $schema)
    {
        Index::_loadIndexes($table, $schema);
        if (isset(Index::$_registry[$schema][$table])) {
            return Index::$_registry[$schema][$table];
        } else {
            return array();
        }
    }

Usage Example

Example #1
0
 /**
  * Validate whether the table exists.
  *
  * @return void
  */
 protected function validateTableAndLoadFields()
 {
     $sql = 'DESCRIBE ' . PMA\libraries\Util::backquote($this->tableName);
     $result = $GLOBALS['dbi']->tryQuery($sql, null, PMA\libraries\DatabaseInterface::QUERY_STORE);
     if (!$result || !$GLOBALS['dbi']->numRows($result)) {
         $this->showMissingTableError();
     }
     if ($this->showKeys) {
         $indexes = PMA\libraries\Index::getFromTable($this->tableName, $this->db);
         $all_columns = array();
         foreach ($indexes as $index) {
             $all_columns = array_merge($all_columns, array_flip(array_keys($index->getColumns())));
         }
         $this->fields = array_keys($all_columns);
     } else {
         while ($row = $GLOBALS['dbi']->fetchRow($result)) {
             $this->fields[] = $row[0];
         }
     }
 }
All Usage Examples Of PMA\libraries\Index::getFromTable