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
  • 3,478
  • 2
  • 8
  • 16
0
$conn->insert_id

will give you last insert id w3schools

vicky
  • 167
  • 4
  • 16
0
$this->db->insert_id();

This will give you last inserted id after inserting record.

Abhijit
  • 105
  • 2
  • 14