diff --git a/src/Command/ImportFromJsonCommand.php b/src/Command/ImportFromJsonCommand.php index d12b791..9995c50 100644 --- a/src/Command/ImportFromJsonCommand.php +++ b/src/Command/ImportFromJsonCommand.php @@ -171,9 +171,12 @@ private function importRoleTypes(OutputInterface $output) $role->setItLabel($roleType['label_it']); $this->em->persist($role); - $this->em->flush(); + if (0 === ($i % $this->batchSize)) { + $this->em->flush(); + } $i++; } + $this->em->flush(); $timeElapsed = microtime(true) - $start; $this->stats[] = ['role_types.json', $timeElapsed, $i]; $output->writeln([sprintf('%s rows imported from roles_types.json', $i)]); @@ -534,7 +537,7 @@ private function importCamps(OutputInterface $output) $metadata->setIdGenerator(new AssignedGenerator()); } $camp->setState($c['state']); - $camp->setLocation(substr($c['location'], 0, 255)); + $camp->setLocation(mb_convert_encoding(substr($c['location'], 0, 255),'UTF-8', 'US-ASCII')); if (isset($c['name'])) { $camp->setName($c['name']); @@ -567,7 +570,7 @@ private function importCamps(OutputInterface $output) } $this->em->persist($camp); - if ($i % 10) { + if(0 == $i % 10) { $this->em->flush(); } $i++;