![]() |
database insert question - 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: database insert question (/showthread.php?tid=11851) |
database insert question - El Forum - 09-25-2008 [eluser]TheoR74[/eluser] Hello, this may be a pretty stuppid question, but here goes.... I have a mysql table with an id field int 11 auto increment. I want to use the $this->db->insert('table_name') function, but I need to know the number that is put into the id field. Is there any easy way to find that out? Thanks Theo database insert question - El Forum - 09-25-2008 [eluser]Yash[/eluser] its pretty simple suppose id name is a_id Code: $data = array( database insert question - El Forum - 09-25-2008 [eluser]Developer13[/eluser] Theo - Here's your answer: After you insert your data, use $this->db->insert_id() to grab the ID of the record just inserted. For example: $newly_inserted_id = $this->db->insert_id(); Found in the user guide: http://ellislab.com/codeigniter/user-guide/database/helpers.html database insert question - El Forum - 09-25-2008 [eluser]TheoR74[/eluser] Thanks Developer13! |