public function getRateCollection() { if (is_null($this->_rateCollection)) { $filter = new Model_Rate_Filter(); $filter->setIdYear($this->getId()); $this->_userCollection = Model_DB_Rate_Mapper::get_instance()->findByFilter($filter); } }
public function getRate($yearId) { if (!isset($this->_rates[$yearId])) { $filter = new Model_Rate_Filter(); $filter->setIdUser($this->getId()); $filter->setIdYear($yearId); $list = Model_DB_Rate_Mapper::get_instance()->findByFilter($filter); if (count($list) > 0) { $this->_rates[$yearId] = $list[0]; } else { $rate = new Model_DB_Rate_Object(); $rate->setIdUserFk($this->getId())->setIdYearFk($yearId)->setRate(0); $rate->save(); $this->_rates[$yearId] = $rate; } } return $this->_rates[$yearId]; }
protected function getWhereClauseByFilter(Model_Rate_Filter $filter) { $where = "1=1 "; $and = " AND "; $adapter = $this->getDbTable()->getAdapter(); if ($filter->getId()) { $where = $adapter->quoteInto(Model_DB_Rate_Table::FIELDS_ID . " = ?", $filter->getId()); } else { $value = $filter->getIdUser(); if (!empty($value)) { $where .= $and . $adapter->quoteInto(Model_DB_Rate_Table::FIELDS_ID_USER_FK . " LIKE ?", "%{$value}%"); } $value = $filter->getIdYear(); if (!empty($value)) { $where .= $and . $adapter->quoteInto(Model_DB_Rate_Table::FIELDS_ID_YEAR_FK . " LIKE ?", "%{$value}%"); } } return $where; }