I am using doctrine to insert bulk data in sql. But after inserting 600 to 700 records it gives an error Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 24 bytes)
I tried increasing the php memory limit but didn't worked .
Here is my code:
function DB_InsertPostTag ($postID, $listSize, $tagList, $tagTypeID,$categoryid) {
$returnVal = 0;
$insertList = array(1=>'');
$insertCount = 0;
sort($tagList);
$tagCount = 0;
for ($i = 0; $i <$listSize; $i++)
{
$tagCount++;
if(isset($tagList[$i+1]))
{
if ($tagList[$i] != $tagList[$i+1])
{
$insertCount++;
$tagList[$i];
$tagCount = 0; //reset the counter
}
}
//else we just ramp the counter
}
$batchSize = 1;
for ($i = 1; $i < $insertCount; $i++)
{
$post_tag = new PostTag();
$post_tag->setPostId($postID);
$post_tag->setCategoryId($categoryid);
$post_tag->setTagId($tagList[$i]);
$post_tag->setTagTypeId($tagTypeID);
$post_tag->setTagCount($tagCount);
$em1 = $this->em;
$em1->persist($post_tag);
$id = $post_tag->getId();
if (($i % $batchSize) == 0) {
$em1->flush();
$em1->clear(); // Detaches all objects from Doctrine!
}
}
$em1->flush();
$em1->clear();
$returnVal = $id;
return $returnVal;
}