src/Db/MySqlDb.php
protected function getIndexes($tablename = '') {
        $ltablename = strtolower($tablename);
        /* @var \PDOStatement */
        $stmt = $this->get(
            'information_schema.STATISTICS',
            [
                'TABLE_SCHEMA' => $this->getDbName(),
                'TABLE_NAME' => $tablename ? $this->px.$tablename : [Db::OP_LIKE => addcslashes($this->px, '_%').'%']
            ],
            [
                'columns' => [
                    'INDEX_NAME',
                    'TABLE_NAME',
                    'NON_UNIQUE',
                    'COLUMN_NAME'
                ],
                'escapeTable' => false,
                'order' => ['TABLE_NAME', 'INDEX_NAME', 'SEQ_IN_INDEX'],
                Db::OPTION_MODE => Db::MODE_PDO
            ]
        );

        $stmt->execute();
        $indexDefs = $stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);

        foreach ($indexDefs as $indexName => $indexRows) {
            $row = reset($indexRows);
            $itablename = strtolower(ltrim_substr($row['TABLE_NAME'], $this->px));
            $index = [
                'name' => $indexName,
                'columns' => array_column($indexRows, 'COLUMN_NAME')
            ];

            if ($indexName === 'PRIMARY') {
                $index['type'] = Db::INDEX_PK;
                $this->tables[$itablename]['indexes'][Db::INDEX_PK] = $index;
            } else {
                $index['type'] = $row['NON_UNIQUE'] ? Db::INDEX_IX : Db::INDEX_UNIQUE;
                $this->tables[$itablename]['indexes'][] = $index;
            }
        }

        if ($ltablename) {
            return valr([$ltablename, 'indexes'], $this->tables, []);
        }
        return null;
    }
protected function getIndexes($tablename = '') {
        $ltablename = strtolower($tablename);
        /* @var \PDOStatement */
        $stmt = $this->get(
            'information_schema.STATISTICS',
            [
                'TABLE_SCHEMA' => $this->getDbName(),
                'TABLE_NAME' => $tablename ? $this->px.$tablename : [Db::OP_LIKE => addcslashes($this->px, '_%').'%']
            ],
            [
                'columns' => [
                    'INDEX_NAME',
                    'TABLE_NAME',
                    'NON_UNIQUE',
                    'COLUMN_NAME'
                ],
                'escapeTable' => false,
                'order' => ['TABLE_NAME', 'INDEX_NAME', 'SEQ_IN_INDEX'],
                Db::OPTION_MODE => Db::MODE_PDO
            ]
        );

        $stmt->execute();
        $indexDefs = $stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);

        foreach ($indexDefs as $indexName => $indexRows) {
            $row = reset($indexRows);
            $itablename = strtolower(ltrim_substr($row['TABLE_NAME'], $this->px));
            $index = [
                'name' => $indexName,
                'columns' => array_column($indexRows, 'COLUMN_NAME')
            ];

            if ($indexName === 'PRIMARY') {
                $index['type'] = Db::INDEX_PK;
                $this->tables[$itablename]['indexes'][Db::INDEX_PK] = $index;
            } else {
                $index['type'] = $row['NON_UNIQUE'] ? Db::INDEX_IX : Db::INDEX_UNIQUE;
                $this->tables[$itablename]['indexes'][] = $index;
            }
        }

        if ($ltablename) {
            return valr([$ltablename, 'indexes'], $this->tables, []);
        }
        return null;
    }
Get the indexes from the database.

@param string $tablename The name of the table to get the indexes for or an empty string to get all indexes.
@return array|null