CodeIgniter Frame BULK INSERT Data

Source: Internet
Author: User
Tags bulk insert codeigniter

  In this paper, we introduce the example of CodeIgniter frame in batch inserting data, and optimize the inserting algorithm, we refer to the use of the bar

  Code as follows: $sub _form = Array ();   $loop = 0;   $ins _loop = 0;   $sum = count ($form _datas);   $this->logger->info (' Insert data total: '. $sum);  //Use of things bulk import helps improve insertion efficiency   $callStartTime = Microtime (true);   $this->db->trans_start ();   foreach ($form _datas as $item) {          $loop + +           $s Ub_form[] = $item;          if ($loop%) = = 0 | | $loop = $sum) {          $this->lo Gger->info (' Insert data num: '. $loop);     $res = $this->kb_object_instance_mdl->insert_batch ($sub _form, $obj _id);     $ins _loop + +;     unset ($sub _form);     if (($ins _loop% 5) = 0) {      $this->logger->info (' Insert data trans_complete Ins_loop : '. $ins _loop);             $this->db->trans_complete ();            if ($loop!= $sUm: {            $this->db->trans_start ();            }    }            }  //$this->db->trans_complete ();   $callEndTime = Microtime (true);   $callTime = $callEndTime-$callStartTime;   $this->logger->info (' Insert data Use time: '. sprintf ('%.4f ', $callTime));      if ($this->db->trans_status () = TRUE) {      $this->_show_msg (' 1 ', Array (' Data ' => ' (' Import OK '));      }else{      $this->_show_error (' saveorupdate error ');     &NBSP}  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.