public function add_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) {

        if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) { // Prevent PRIMARY to be added (only in create table, being serious  :-P)
            throw new ddl_exception('ddlunknownerror', null, 'Primary Keys can be added at table create time only');
        }

        if (!$sqlarr = $this->generator->getAddKeySQL($xmldb_table, $xmldb_key)) {
            return; //Empty array = nothing to do = no error
        }

        $this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
    }
public function add_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key) {

        if ($xmldb_key->getType() == XMLDB_KEY_PRIMARY) { // Prevent PRIMARY to be added (only in create table, being serious  :-P)
            throw new ddl_exception('ddlunknownerror', null, 'Primary Keys can be added at table create time only');
        }

        if (!$sqlarr = $this->generator->getAddKeySQL($xmldb_table, $xmldb_key)) {
            return; //Empty array = nothing to do = no error
        }

        $this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
    }
public function add_key ( xmldb_table $ xmldb_table , xmldb_key $ xmldb_key ) { if ( $ xmldb_key -> getType ( ) == XMLDB_KEY_PRIMARY ) { // Prevent PRIMARY to be added (only in create table, being serious  :-P) throw new ddl_exception ( 'ddlunknownerror' , null , 'Primary Keys can be added at table create time only' ) ; } if ( ! $ sqlarr = $ this -> generator -> getAddKeySQL ( $ xmldb_table , $ xmldb_key ) ) { return ; //Empty array = nothing to do = no error } $ this -> execute_sql_arr ( $ sqlarr , array ( $ xmldb_table -> getName ( ) ) ) ; }
This function will create the key in the table passed as arguments

@param xmldb_table $xmldb_table Table object (just the name is mandatory).
@param xmldb_key $xmldb_key Index object (full specs are required).
@return void
This function will create the key in the table passed as arguments