We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Phalcon insert multiple rows

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();


  $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 . " ";

    } else {




This is for importing a spreadsheet? How big is the expected spreadsheet? I'd say if it's less than 5000 rows - which is just a number I pulled from my head - then don't worry about inserting multiple rows. In my experience, imports like this happen so rarely (relative to the usage of the app) that it's a waste of time over-optimizing the process.