$sub_form = array();<BR> $loop = 0;<BR> $ins_loop = 0;<BR> $sum = count($form_datas);<BR> $this->logger->info('insert data total:'.$sum);<BR> //使用事物批量导入有助于提高插入效率<BR> $callStartTime = microtime(true);<BR> $this->db->trans_start();<BR> foreach ( $form_datas as $item ) {<BR> $loop ++;<BR> $sub_form[] = $item;<BR> if(($loop % 200) == 0 || $loop == $sum){<BR> $this->logger->info('insert data num:'.$loop);<BR> $res = $this->kb_object_instance_mdl->insert_batch($sub_form,$obj_id);<BR> $ins_loop ++;<BR> unset($sub_form);<BR> if(($ins_loop % <span>%本文来源gaodai#ma#com搞*代#码9网#</span><strong>搞gaodaima代码</strong>5) == 0){<BR> $this->logger->info('insert data trans_complete ins_loop:'.$ins_loop);<BR> $this->db->trans_complete();<BR> if($loop != $sum){<BR> $this->db->trans_start();<BR> }<BR> }<BR> }<BR> }<BR> //$this->db->trans_complete();<BR> $callEndTime = microtime(true);<BR> $callTime = $callEndTime - $callStartTime;<BR> $this->logger->info('insert data use time:'.sprintf('%.4f',$callTime));<BR> if($this->db->trans_status() === TRUE){<BR> $this->_show_msg('1',array('data'=>'import ok'));<BR> }else{<BR> $this->_show_error('saveOrUpdate error');<BR> }<BR>