How to add data having foreign key |
I have to insert data into my data base it contains foreign key and I am unable to find any guide which tells how insert thin in codeigniter. Can any one help me out
If you mean that you need the last insert key of a new data to map it as foreign key, than you can get it like that:
PHP Code: $this->db->insert('table',$data);
You may be inserting a foreign key ID in a 'child' table that doesn't yet exist in the 'parent' table. Make sure that the foreign key actually exists in the 'parent' table before referencing it in the 'child'.
|
Welcome Guest, Not a member yet? Register Sign In |