Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eabreusantos/567c20ec306ce7d12affd8fc44e87700 to your computer and use it in GitHub Desktop.
Save eabreusantos/567c20ec306ce7d12affd8fc44e87700 to your computer and use it in GitHub Desktop.
importTest
class Engine {
public function run() {
$batchSize = 100;
foreach($this->file->fetchAll() as $lineNumber => $line) {
if($this->validator->validate($line,$lineNumber)) {
$this->rowSuccess($line, $lineNumber);
} else {
$this->rowError($line, $lineNumber);
}
if (($i % $batchSize) ===0) {
$em->flush();
$em->clear();
}
}
$em->flush();
$em->clear();
}
}
class importacao1 extends Engine {
public function rowSuccess($line) {
$col1 = $this->getColumn(1);
//Verifica se linha ja existe
$entity = $this->getFromDatabase($col1);
if (!empty($entity)) {
$entity->setValue(1);
} else {
$entity = new Entity();
$entity->setValue();
$em->persist($entity);
}
}
public function rowError($line,$lineNumber) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment