Welcome Guest, Not a member yet? Register   Sign In
How to add data having foreign key
#1
Star 

I have to insert data into my data base it contains foreign key and I am unable to find any guide Sad which tells how insert thin in codeigniter. Can any one help me out Smile
Reply
#2

Please rephrase. Your question is not clear.
Reply
#3

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);
$fk_id $this->db->insert_id(); 

Reply
#4

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'.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB