/** * Gets all the account lines for this billrun from the db * @param int $aid the account id * @param int $start_time lower bound date to get lines from. A unix timestamp * @return Mongodloid_Cursor the mongo cursor used to iterate over the lines * @todo remove aid parameter */ protected function getAccountLines($aid, $start_time = 0, $include_flats = true) { $start_time = new MongoDate($start_time); $end_time = new MongoDate(Billrun_Util::getEndTime($this->billrun_key)); $query = array('aid' => $aid, 'urt' => array('$lte' => $end_time, '$gte' => $start_time)); if (!$include_flats) { $query['type'] = array('$ne' => 'flat'); } if ($this->allowOverride == 1) { $query['billrun']['$in'] = array('000000', $this->billrun_key); } else { if ($this->allowOverride == 2) { $query['billrun'] = $this->billrun_key; } else { $query['billrun'] = '000000'; } } $hint = array('aid' => 1, 'urt' => 1); $sort = array('aid' => 1, 'urt' => 1); Billrun_Factory::log()->log("Querying for account " . $aid . " lines", Zend_Log::INFO); $cursor = $this->lines->query($query)->cursor()->fields($this->filter_fields)->sort($sort)->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'))->hint($hint); Billrun_Factory::log()->log("Finished querying for account " . $aid . " lines", Zend_Log::INFO); // $results = array(); // Billrun_Factory::log()->log("Saving account " . $aid . " lines to array", Zend_Log::DEBUG); // foreach ($cursor as $entity) { // $results[] = $entity; // } // Billrun_Factory::log()->log("Finished saving account " . $aid . " lines to array", Zend_Log::DEBUG); // return $results; return $cursor; }
/** * Updates the billrun object to match the db * @return Billrun_Billrun */ protected function load() { $this->data = $this->billrun_coll->query(array('aid' => $this->aid, 'billrun_key' => $this->billrun_key))->cursor()->limit(1)->current(); $this->data->collection($this->billrun_coll); return $this; }