Refactor to use bulk processing best practice based on doctrine docs #274
Reference: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/batch-processing.html
This commit is contained in:
parent
d094b5e8d9
commit
142e34ba31
1 changed files with 9 additions and 5 deletions
|
|
@ -87,14 +87,17 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
// get all warranties
|
||||
error_log('Getting warranties...');
|
||||
$warr_q = $this->em->createQuery('select w from App\Entity\Warranty w where w.mobile_number is not null');
|
||||
$warranties = $warr_q->getResult();
|
||||
$warranties = $warr_q->iterate();
|
||||
// $warranties = $warr_q->getResult();
|
||||
// $warranties = $this->em->getRepository(Warranty::class)->findAll();
|
||||
|
||||
$invalid_warranties = [];
|
||||
$warr_count = count($warranties);
|
||||
$output->writeln("Processing $warr_count warranties... ");
|
||||
foreach($warranties as $warr)
|
||||
{
|
||||
// $warr_count = count($warranties);
|
||||
$output->writeln("Processing warranties... ");
|
||||
foreach($warranties as $row)
|
||||
{
|
||||
$warr = $row[0];
|
||||
|
||||
$total_warr++;
|
||||
// check if warranty mobile already exists in customer
|
||||
$w_mobile = $warr->getMobileNumber();
|
||||
|
|
@ -209,6 +212,7 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
*/
|
||||
}
|
||||
}
|
||||
$this->em->clear();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue