I'm running this code, that's is possible to insert multiple (pdo transaction)? because i'm sure this code can impact to perfomance
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($upload_dir.$filename);
$sheetData = $spreadsheet->getActiveSheet();
$data = $sheetData->toArray();
if (count($data> 1)){
foreach($data as $row => $col){
if($row >= 1){//skip row 1
$import->name = $col[0];//get value cell A
$import->number = $col[1];//get value cell B
$import->filename = $filename;//get value cell B
}
if (!$import->save()){
$err = "";
foreach ($import->getMessages() as $key => $value)
{
$err .= $value . " ";
}
$this->flash->error($value);
} else {
$this->flash->success("success");
}
}
}