-3

I have thousand of data from an webservice . but nusoap limit execution time only 30 second . I can't insert all those data because of this limit . I can't change nusoap setting because is on server . . is there anyway to fix that ? . EDIT 1 i tried split big data to array chunk, but after 30 second is over here's my code (using code igniter)

$this->db->trans_start();
$_datas = array_chunk($data["result"], 300);
foreach ($_datas as $key => $data) {
$insert=$this->db->insert_batch('temp_mahasiswa', $data);
if (!$insert && $this->db->error()) {
     //some logics here, you may create some string here to alert user
 echo "Data nim"; echo " "; echo $key['nipd'] ; echo " ";  echo "Sudah Ada"; echo '<br>'; 
}else {
   //other logics here
echo "Data nim"; echo " "; echo $key['nipd'] ; echo " ";  echo "Sudah Masuk"; echo '<br>';
}
}
$this->db->update('temp_mahasiswa',$tambah);

$this->db->trans_complete();
Billy Adelphia
  • 33
  • 1
  • 1
  • 9

1 Answers1

0

Way 1

You can insert data with LOAD DATA: http://dev.mysql.com/doc/refman/5.7/en/load-data.html

it is much faster than INSERT.

Way2

You can create queue (for example with Beanstalk) and background job what will insert data.

Community
  • 1
  • 1
Nick
  • 9,735
  • 7
  • 59
  • 89