/** * Creates and saves a flat line to the db * @param Billrun_Subscriber $subscriber the subscriber to create a flat line to * @param string $billrun_key the billrun for which to add the flat line * @return array the inserted line or the old one if it already exists */ protected function saveFlatLine($subscriber, $billrun_key) { $flat_entry = $subscriber->getFlatEntry($billrun_key, true); try { $this->lines->insert($flat_entry->getRawData(), array("w" => 1)); } catch (Exception $e) { if ($e->getCode() == 11000) { Billrun_Factory::log("Flat line already exists for subscriber " . $subscriber->sid . " for billrun " . $billrun_key, Zend_log::ALERT); } else { Billrun_Factory::log("Problem inserting flat line for subscriber " . $subscriber->sid . " for billrun " . $billrun_key . ". error message: " . $e->getMessage() . ". error code: " . $e->getCode(), Zend_log::ALERT); Billrun_Util::logFailedCreditRow($flat_entry->getRawData()); } } return $flat_entry; }