title: $this->db->insert_id(); returning 0 every time in codeigniter
body: <p>I am using codeigniter and inserting one record at a time. But the problem is that $this->db->insert_id(); is returning 0 every time, however record is getting created successfully. I am unable to figure it out. Is this usual case or I am doing some silly mistake. I have used email_id as primary key and mobile no as unique. </p>
  
  <p>Here is my code of modal:</p>
  
  <pre><code>function signup_insert($data) {
  
          $result = $this-&gt;db-&gt;insert('registration_detail', $data);
          $insert_id = $this-&gt;db-&gt;insert_id();
          return $insert_id;
      }
  </code></pre>
  
  <p>And this is my code of controller:</p>
  
  <pre><code>function insert_signup() {
          $email = $this-&gt;input-&gt;get('email');
          $name = $this-&gt;input-&gt;get('name');
          $password1 = $this-&gt;input-&gt;get('password1');
          $password2 = $this-&gt;input-&gt;get('password2');
          $phone = $this-&gt;input-&gt;get('phone');
          $country = $this-&gt;input-&gt;get('country');
  
          $data = array(
              'email' =&gt; $email,
              'name' =&gt; $name,
              'pwd' =&gt; $password1,
              'phone' =&gt; $phone,
              'country' =&gt; $country
          );
  
          $insert_id = $this-&gt;signup-&gt;signup_insert($data);
          print_r($insert_id);
      }
  </code></pre>