Example #1
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return VoteCommentRate the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Example #2
0
	public function actionDel($id)
	{
		$model = Rate::model()->findByPk($id);
		if($model->delete()){
			Yii::app()->user->setFlash('success','删除成功!');
		}else{
			Yii::app()->user->setFlash('error','删除失败,请重试!');
		}
		$this->redirect(array('list'));
	}
Example #3
0
	private function currencyList()
	{
		$tempArr = array();
		$arr = Rate::model()->findAll(array(
				'select'=>'id,code',
				));
		
		if(!empty($arr)){
			foreach($arr as $value){
				$tempArr[$value->id] = $value->code;
			}
		}
		
		return $tempArr;
	}
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Rate the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Rate::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #5
0
	protected function getRateValue($from_Currency,$to_Currency)
	{
		$rate = 1;
		$rateConfigModel = RateConfig::model()->findByPk(1);
		if($rateConfigModel!=null){
			if($rateConfigModel->autochange == 1){//使用实时汇率
				$rate = $this->ExchangeRate($from_Currency,$to_Currency);
			}else{
				$rateModel = Rate::model()->find(array('select'=>'rate','condition'=>"code='$to_Currency'"));
				$rate = $rateModel->rate;
			}
		}
	
		return $rate;
	}
 /**
  * 判断一个用户是否评价者
  * @param unknown_type $userId
  */
 public function hasRated($userId)
 {
     $owner = $this->getOwner();
     if (!$owner->entityId) {
         return false;
     }
     $rate = Rate::model()->findByAttributes(array('userId' => $userId, 'rateableEntityId' => $owner->entityId));
     if (!$rate) {
         return false;
     }
     return true;
 }