Last active
October 10, 2017 12:31
-
-
Save MaximStrutinskiy/30867353ec51f747182faf2b46e65a5a to your computer and use it in GitHub Desktop.
Doctrine Bulk Inserts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach ($nominals as $nominal) { | |
for ($i = 1; $i <= $nominal['code_count']; $i++) { | |
$code = new Code(); | |
$code->setShop($shop); | |
$code->setCode($this->GenerateData($codeLength, $codeType, $codePrefix)); | |
$code->setPincode($this->GenerateData($pincodeLength, $pincodeType)); | |
$code->setCodeLiveCikle($codeLiveCikle); | |
$code->setMinDateActivity($minDateActivity); | |
$code->setMaxDateActivity($maxDateActivity); | |
$code->setDateCreated($dateCreate); | |
if ($nominalStatus) { | |
$code->setValue($nominal['code_nominal']); | |
} else { | |
$code->setValue(0); | |
}; | |
$app['orm.em']->persist($code); | |
if (($i % $batchSize) === 0) { | |
$app['orm.em']->flush(); | |
$app['orm.em']->clear(); | |
} | |
} | |
$app['orm.em']->flush(); | |
$app['orm.em']->clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment