Creating a foreign key - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Creating a foreign key (/showthread.php?tid=362) |
Creating a foreign key - cerberus478 - 11-25-2014 Hi, I would like to know how to create a foreign key in codeigniter's migration RE: Creating a foreign key - Rufnex - 11-25-2014 Right know this must be done by a custom query like PHP Code: $this->db->query('alter table ....'); For mysqli there was a project to do that but i dont know if it works https://github.com/DamexHr/CodeIgniter/tree/feature/add_foreign_key/ RE: Creating a foreign key - glorsh66 - 10-13-2017 I also encountered such problem with foreign keys Can't make it using query builder. some people advise something like this, but i can't make it work; $this->dbforge->add_field('id INT NOT NULL AUTO_INCREMENT PRIMARY KEY'); $this->dbforge->add_field('CONSTRAINT FOREIGN KEY (id) REFERENCES table(id)'); Is it possible in current version of codeigniter? |