I am using codeigniter and I am trying to convert following query into dbforge style query, how can I do it?
create table filter (
    filterid int primary key auto_increment,
    filtername varchar(50) not null,
    categoryid int not null,
    isactive tinyint not null,
    sequence int not null,
    foreign key(categoryid) references category(id));
                Here are 4 ways to do that. The first three work with create_table and the fourth one can be done when adding a field later.
$this->dbforge->add_field('id INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
$this->dbforge->add_field('CONSTRAINT FOREIGN KEY (id) REFERENCES table(id)');
$this->dbforge->add_field('INDEX (deleted)');
$this->dbforge->add_column('table',[
    'COLUMN id INT NULL AFTER field',
    'CONSTRAINT fk_id FOREIGN KEY(id) REFERENCES table(id)',
]);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With