database insert question |
[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
[eluser]Yash[/eluser]
its pretty simple suppose id name is a_id Code: $data = array(
[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-gui...lpers.html
|
Welcome Guest, Not a member yet? Register Sign In |