<?php
die;
set_time_limit(0);
ini_set('memory_limit','1024M');
ini_set('post_max_size','32M');
ini_set('upload_max_filesize ','32M');

$destdir  = "live-data-migration-csvs/";
$name     = "contact_list.csv";
$destfile = $destdir.$name;  

$batch_size = 3000;
$table_name = "job";
$records_inserted = 0;
$records_updated = 0;  
                                   
$flag = true;
$fp = fopen($destfile, 'r');
while (!feof ($fp)){
  $buffer = fgetcsv($fp, 1000000, ',');  
  if($flag) { 
	  if($buffer){
			$variable_array = array("first_name","last_name","email","phone","company");
			foreach($variable_array as $key=>$val){		
				${$val} = addslashes(trim(strtolower($buffer[$key])));
			}
			if($first_name =="first_name"){
				continue;
			}
			
			
			$enquiry_date = date("Y-m-d");
			
			$records_inserted++;
			$sql =  "INSERT INTO $table_name(`is_enquiry`,`enquiry_date`,`first_name`,`last_name`,`phone_no`,`email`,`company_name`) VALUE('1','$enquiry_date','$first_name','$last_name','$phone','$email','$company')";
			
			mysqli_query($conn,$sql);
	  }
  }
}
?>
<?php 
if($records_inserted){    
  echo '<br><span style="font-family:calibri;color:red;">'.($records_inserted).' records has been inserted...</span>';
}?>
 <?php 
if($records_updated){    
  echo '<br><span style="font-family:calibri;color:red;">'.($records_updated).' records has been updated...</span>';
}?>