I have a code to upload xlsx to Mysql tables and the load is done with chunks because the file is too large, so I have to INSERT every chunk. The for loop works good it has been tested with echo statements but the INSERT is only done in the first chunk. Any idea of how I can solve this? This is part of the code:
for ($startRow = 2; $startRow <= $totalRows; $startRow += $chunkSize) {
$chunkFilter->setRows($startRow,$chunkSize);
//Load of the data
$objPHPExcel = $objReader->load($newFilePath);
$objWorksheet4 = $objPHPExcel -> getSheetByName("MIFReportExport");
//Getting data of every cell
$highestRow4 = $objWorksheet4->getHighestRow();
$highestColumn4 = $objWorksheet4->getHighestColumn();
$highestColumnIndex4 = PHPExcel_Cell::columnIndexFromString($highestColumn4);
$rows = array();
for ($row = 2; $row <= $highestRow4; ++$row) {
for ($col = 0; $col <= $highestColumnIndex4; ++$col) {
$rows[$col] = $objWorksheet4->getCellByColumnAndRow($col, $row)->getCalculatedValue();
}
$result = mysql_query("INSERT INTO fy16 (SerialNumber, BrandedModelName, GenericProductCode, Familia, ProductLineModelFile)VALUES ('".$rows[0]."', '".$rows[1]."', '".$rows[2]."', '".$rows[3]."', '".$rows[4]."', '".$rows[5]."')",$con) or die(mysql_error());
}
}
Thanks in advance.