Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $batchSize = 100; //Entity Manager will flush every batchSize times
- $i = 0;
- foreach ($aTagCollection as $oTag) {
- $aMapping = $oTag->getMapping();
- foreach ($aMapping as $oMapping) {
- }
- if (($i % $batchSize) === 0) {
- $this->em->flush(); //Execute all updates every 100 times
- $this->em->clear(); //Detaches all objects from Doctrine
- }
- $i++;
- }
- $this->em->flush();
- /** @ORMOneToMany(targetEntity="Mapping",
- mappedBy="customerLabel", fetch="EXTRA_LAZY",
- cascade={"persist"}, orphanRemoval=true)
- */
- private $mapping;
- public function __construct()
- {
- $this->mapping = new ArrayCollection();
- }
- public function addMapping(Mapping $mapping)
- {
- $this->mapping[] = $mapping;
- return $this;
- }
- public function removeMapping(Mapping $mapping)
- {
- $this->mapping->removeElement($mapping);
- }
- public function getMapping()
- {
- return $this->mapping;
- }
- /**
- * @ORMManyToOne(targetEntity="Tag", inversedBy="mapping", cascade={"persist"})
- * @ORMJoinColumn(name="tag_id", referencedColumnName="id", onDelete="CASCADE")
- */
- private $tag;
- public function setTag(Tag $tag = null)
- {
- $this->tag= $tag;
- return $this;
- }
- public function getTag()
- {
- return $this->tag;
- }
Add Comment
Please, Sign In to add comment