PMA\libraries\Index::_loadIndexes PHP Method

_loadIndexes() private static method

Load index data for table
private static _loadIndexes ( string $table, string $schema ) : boolean
$table string table
$schema string schema
return boolean whether loading was successful
    private static function _loadIndexes($table, $schema)
    {
        if (isset(Index::$_registry[$schema][$table])) {
            return true;
        }
        $_raw_indexes = $GLOBALS['dbi']->getTableIndexes($schema, $table);
        foreach ($_raw_indexes as $_each_index) {
            $_each_index['Schema'] = $schema;
            $keyName = $_each_index['Key_name'];
            if (!isset(Index::$_registry[$schema][$table][$keyName])) {
                $key = new Index($_each_index);
                Index::$_registry[$schema][$table][$keyName] = $key;
            } else {
                $key = Index::$_registry[$schema][$table][$keyName];
            }
            $key->addColumn($_each_index);
        }
        return true;
    }

Usage Example

Example #1
0
 /**
  * return primary if set, false otherwise
  *
  * @param string $table  table
  * @param string $schema schema
  *
  * @return mixed primary index or false if no one exists
  */
 public static function getPrimary($table, $schema)
 {
     Index::_loadIndexes($table, $schema);
     if (isset(Index::$_registry[$schema][$table]['PRIMARY'])) {
         return Index::$_registry[$schema][$table]['PRIMARY'];
     } else {
         return false;
     }
 }