Welcome Guest, Not a member yet? Register   Sign In
get and post ID to new join table
#1

Hi everyone,
I'm coding a Stock Management System to manage order and deliveries. My system is design in a way that when an order is placed, the Admin logs in to the Order list, clicks on Stock where a page comes up and he has to provide details of the delivery including changing the status.
 But when i join tables order and stock i cant record any information in the database anymore. the system dysplays

Error Number: 1452
Cannot add or update a child row: a foreign key constraint fails (`data`.`stock`, CONSTRAINT `stock_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `sm_storage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)


Please could anyone explain how to post ids from parent table to child table

Attached Files Thumbnail(s)
   
Reply
#2

Hello. Is it CI 3 or 4? I make a guess; your UPDATE query is including the foreign key ID. Maybe you can try making the query without touching that column that has foreign key constraint. Which CI method are you using? There are

->db->query()
->db->replace()
->db->set()
->db->update()
Reply




Theme © iAndrew 2016 - Forum software by © MyBB