1

I inserted records in database with auto generated id, now i want to get that id when i click on submit button that brings me multi file upload page

3 Answers3

0

Try this

function add_post($post_data){
   $this->db->insert('posts', $post_data);
   $insert_id = $this->db->insert_id();

   return  $insert_id;
}

In case of multiple inserts you could use

$this->db->trans_start();
$this->db->trans_complete();
Serghei Leonenco
  • 2,875
  • 2
  • 5
  • 13
0
$conn->insert_id

will give you last insert id w3schools

vicky
  • 137
  • 3
  • 14
0
$this->db->insert_id();

This will give you last inserted id after inserting record.

Abhijit
  • 95
  • 2
  • 12