コード例 #1
0
 /**
  * @param $row
  * @param \Model_DB_Rate_Object $db_model
  * @return Model_DB_Rate_Object
  */
 public function parseRow($row, Model_DB_Rate_Object $db_model = null)
 {
     if (null === $db_model) {
         $db_model = new Model_DB_Rate_Object();
     }
     return $db_model->setIdYearFk($row[Model_DB_Rate_Table::FIELDS_ID_YEAR_FK])->setRate($row[Model_DB_Rate_Table::FIELDS_RATE])->setIdUserFk($row[Model_DB_Rate_Table::FIELDS_ID_USER_FK])->setId($row[Model_DB_Rate_Table::FIELDS_ID]);
 }
コード例 #2
0
 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];
 }