public function find_index_name(xmldb_table $xmldb_table, xmldb_index $xmldb_index, $returnall = false) {
        // Calculate the name of the table
        $tablename = $xmldb_table->getName();

        // Check the table exists
        if (!$this->table_exists($xmldb_table)) {
            throw new ddl_table_missing_exception($tablename);
        }

        // Extract index columns
        $indcolumns = $xmldb_index->getFields();

        // Get list of indexes in table
        $indexes = $this->mdb->get_indexes($tablename);

        $return = array();

        // Iterate over them looking for columns coincidence
        foreach ($indexes as $indexname => $index) {
            $columns = $index['columns'];
            // Check if index matches queried index
            $diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns));
            // If no differences, we have find the index
            if (empty($diferences)) {
                if ($returnall) {
                    $return[] = $indexname;
                } else {
                    return $indexname;
                }
            }
        }

        if ($return and $returnall) {
            return $return;
        }

        // Arriving here, index not found
        return false;
    }
public function find_index_name(xmldb_table $xmldb_table, xmldb_index $xmldb_index, $returnall = false) {
        // Calculate the name of the table
        $tablename = $xmldb_table->getName();

        // Check the table exists
        if (!$this->table_exists($xmldb_table)) {
            throw new ddl_table_missing_exception($tablename);
        }

        // Extract index columns
        $indcolumns = $xmldb_index->getFields();

        // Get list of indexes in table
        $indexes = $this->mdb->get_indexes($tablename);

        $return = array();

        // Iterate over them looking for columns coincidence
        foreach ($indexes as $indexname => $index) {
            $columns = $index['columns'];
            // Check if index matches queried index
            $diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns));
            // If no differences, we have find the index
            if (empty($diferences)) {
                if ($returnall) {
                    $return[] = $indexname;
                } else {
                    return $indexname;
                }
            }
        }

        if ($return and $returnall) {
            return $return;
        }

        // Arriving here, index not found
        return false;
    }
public function find_index_name ( xmldb_table $ xmldb_table , xmldb_index $ xmldb_index , $ returnall = false ) { // Calculate the name of the table $ tablename = $ xmldb_table -> getName ( ) ; // Check the table exists if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ tablename ) ; } // Extract index columns $ indcolumns = $ xmldb_index -> getFields ( ) ; // Get list of indexes in table $ indexes = $ this -> mdb -> get_indexes ( $ tablename ) ; $ return = array ( ) ; // Iterate over them looking for columns coincidence foreach ( $ indexes as $ indexname => $ index ) { $ columns = $ index [ 'columns' ] ; // Check if index matches queried index $ diferences = array_merge ( array_diff ( $ columns , $ indcolumns ) , array_diff ( $ indcolumns , $ columns ) ) ; // If no differences, we have find the index if ( empty ( $ diferences ) ) { if ( $ returnall ) { $ return [ ] = $ indexname ; } else { return $ indexname ; } } } if ( $ return and $ returnall ) { return $ return ; } // Arriving here, index not found return false ; }
Given one xmldb_index, the function returns the name of the index in DB
of false if it doesn't exist

@param xmldb_table $xmldb_table table to be searched
@param xmldb_index $xmldb_index the index to be searched
@param bool $returnall true means return array of all indexes, false means first index only as string
@return array|string|bool Index name, array of index names or false if no indexes are found.
@throws ddl_table_missing_exception Thrown when table is not found.
Given one xmldb_index the function returns the name of the index in DB of false if it doesn t exist