![]() |
Multiple inserts and last insert id - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multiple inserts and last insert id (/showthread.php?tid=47489) |
Multiple inserts and last insert id - El Forum - 12-10-2011 [eluser]Unknown[/eluser] Does Codeigniter 2 have a cleaner way of doing what's shown in the code, below? As you can see, I'm trying to insert data, via POST, into 3 separate tables that are related to each other. Once I insert into table1, I want to grab its last insert id and enter that as the value for table2_id and table3_id (foreign key). I've Googled this and this and people have mentioned db transactions but I was wondering if there's also a way without transactions. Just curious, being a CI newbie. Here's the code: Code: public function create() Thanks ![]() |