• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Mod installation: Altering Database Tables

#1
In vBulletin I was used to alter database tables like this:

PHP:
        $dbalter->fetch_table_info('tablename');
         $dbalter->add_field(array(
            'name'       => 'fieldname',
            'type'       => 'int',
            'length'       => '10',
            'null'       => false,
            'default'    => '0'
        ), false);
But this commands are not working anymore. How do they have to look like?
 
#2
This is kind of dirty, and there is probably a better way to do this, but this should work.

PHP:
// to add a column to a table
$db->query('ALTER TABLE the_table ADD COLUMN randomCol INT(10) NOT NULL DEFAULT 0;');

// to remove a column from a table
$db->query('ALTER TABLE the_table DROP COLUMN randomCol;');