> Just post your source already. > ok, the complete workflow is a little bit complicated. we are using a workflow engine and the newsletter generator is one step of three. the first cleans the statistics data, the second generates the new data and the third is the one which generates the mails. here is the concerning method: /** * This method generates the monthly newsletter with the statistics block for the specified period. * * @param NewsletterValue $vo Initialized NewsletterValue object * @param Integer $dateFrom Timestamp representing the start date of the period * @param Integer $dateTo Timestamp representing the end date of the period */ private final function generateMonthlyNewsletter($vo, $dateFrom, $dateTo){ $this->logger->debug("Generating monthly newsletter with statistics blocks."); // initialize variable for the abonents $abonents = null; // read the newsletter template $asset = $vo->getAsset(); $theData = self::readTemplate("../../../" . $this->templatePath . $asset->getFileName()); $this->logger->debug("successfully read template, MEMORY USAGE: " . memory_get_usage()/1048576 . " MB"); // iterate over the abonents and generate customized newsletter content $counter = 0; $start = 0; $offset = self::PROCESS_ABONENTS; // get the first newsletter abonents $personAction = new PersonEPBAction(); $abonents = $personAction->findAbonents($start, $offset); $size = $personAction->countFoundRows(); $this->logger->debug("Found " . $size . " abonents...."); $loops = ceil($size/self::PROCESS_ABONENTS); $this->logger->debug("Need " . $loops . " loops at " . self::PROCESS_ABONENTS . " abonents per loop"); for($i = 0; $i < $loops; $i++){ $start = $i*self::PROCESS_ABONENTS; $abonents = $personAction->findAbonents($start, self::PROCESS_ABONENTS); $this->logger->debug("Loop " . $i . ", MEMORY USAGE: " . memory_get_usage()/1048576 . " MB"); foreach($abonents as $person){ $this->logger->debug("Generating mail for " . $person->getPersonId() . ", " . $person->getFullName()); // replace custom person fields $text = self::replaceTemplateVars($theData, $person, $dateFrom, $dateTo); // add statistics $text = self::addStatisticsBlocks($text, $person); // add the text to the person_newsletter table $lvo = new PersonNewsletterLightValue(); $lvo->setNewsletterIdFk($vo->getNewsletterId()); $lvo->setPersonIdFk($person->getPersonId()); $lvo->setMimeTypeIdFk(2); // text/html TODO: refactor! $lvo->setName("brainGuide AG"); // TODO: refactor! $lvo->setEmail("service@xxxxxxxxxxxxxx"); // TODO: refactor! $lvo->setMailto($person->getEmailBusiness()); $lvo->setSubject($vo->getSubject()); $lvo->setText($text); $lvo->setTstamp(time()); $lvo->setSent(0); $lvo->setViewed(0); self::savePersonNewsletter($lvo); // unset variables // unset($text, $lvo); $text = null; $lvo = null; sleep(1); } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php