title: how to insert last_insert_id in sql query of csv query?
body: <p>i am importing csv data into mysql database using codegniter framework. my database has two table promotion and promotion_product.promotion table is 3 fields name as promotion_id,name,start_dateand end_date.promotion_id is the primary key of promotion table.promotion_id is the auto incremment.promotion_product table is 5 fields id,promotion_id,sku,price,map.   promotion_id is the foreign key of this table. i am importing csv file this table.csv field is sku,price and map.i am not getting how to insert promotion_id of promotion_porduct table.i am using last_insert_id.my code is below:</p>
  
  <p>my model is:</p>
  
  <pre><code>     public function save_csv($data,$data1) {
  
              $this-&gt;db-&gt;insert('promotion', $data1);
              $insert_id = $this-&gt;db-&gt;insert_id();
              print_r($insert_id);
              $infile = $data['upload_data']['full_path'];
              //print_r($infile);
  
              $sql = "LOAD DATA INFILE '" . $infile . "'
                              INTO TABLE promotion_product
                              FIELDS TERMINATED BY ','
                              OPTIONALLY ENCLOSED BY '\"' 
                              LINES TERMINATED BY '\r'
                              IGNORE 1 LINES 
                              (promotion_id,sku, price, map)";
              print_r($sql);
              $query = $this-&gt;db-&gt;query($sql);
  
              //var_dump($query);
  
              return $query;
          }
  </code></pre>