title: How to get the id of multiple insert in codeigniter
body: <p>I am writing a Codeigniter script where I have inserted multiple rows using foreach . I want to get all the last inserted id's. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>public function savePickupDataModal($dates, $pickData) {
      foreach ($dates['dates'] as $date) {
          $sql = 'INSERT INTO pickupManagement (dates, readyhour, readymint, readyformat, latesthour, latestmint, latestformat, approxVal, otherComment) ' .
                      'VALUES("' . $date . '","' . $pickData['readyhour'] . '","' . $pickData['readymint'] . '","' . $pickData['readyformat'] . '","' . $pickData['latesthour'] . '","' . $pickData['latestmint'] . '","' . $pickData['latestformat'] . '","' . $pickData['approxVal'] . '","' . $pickData['otherComment'] . '")';
          $query = $this-&gt;db-&gt;query($sql);
          if ($this-&gt;db-&gt;affected_rows() &gt; 0) {
              return true;
          } else {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>Here the date array contains any number of dates like 3, 4 or 5 so the insert query will be executed until the array contains the number of dates. </p>
  
  <p>How do I get all the last inserted records id's?</p>