Welcome Guest, Not a member yet? Register   Sign In
inserting into multiple tables from one form
#5

[eluser]matt.asbury[/eluser]
Hi Todlerone

And TGIF indeed. I assume you have a field in the second table to contain the foreign key from the first table?
All you would need to do, as noctum suggested, is to insert the set of fields you need into the first table (I assume things like name) and then after you have inserted the record into the database, you set a variable for your new foreign key using the insert_id() function:
Code:
$foreign_key = $this->db->insert_id();
You can then start inserting a new record into the second (schedule) table setting the value of the field you are using to contain your foreign key to the created variable.


Messages In This Thread
inserting into multiple tables from one form - by El Forum - 11-12-2010, 03:32 PM
inserting into multiple tables from one form - by El Forum - 11-12-2010, 03:36 PM
inserting into multiple tables from one form - by El Forum - 11-12-2010, 03:42 PM
inserting into multiple tables from one form - by El Forum - 11-12-2010, 04:14 PM
inserting into multiple tables from one form - by El Forum - 11-12-2010, 05:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB