Shekhar Joshi Shekhar Joshi - 7 months ago 138
SQL Question

How to use dbforge[of codeigniter] to add foreign key

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));

Answer

use $this->db->query(); instead.

this always work for me.

$sql="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))";

$this->db-query($sql);
Comments