Welcome Guest, Not a member yet? Register   Sign In
Creating a foreign key
#1

Hi,

I would like to know how to create a foreign key in codeigniter's migration
Reply
#2

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/t...reign_key/

Reply
#3

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?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB