Ejemplo n.º 1
0
 /**
  * 设置测试次数
  * @param integer $uid
  */
 public function setTestCount($uid)
 {
     $condition['uid'] = $uid;
     $count = Survey::find()->where($condition)->count();
     $testing_count = Survey::find()->where($condition)->sum('answer_count');
     $model_UserProfile = UserProfile::findOne($uid);
     $model_UserProfile ? null : ($model_UserProfile = new UserProfile());
     $model_UserProfile->uid = $uid;
     $model_UserProfile->test_count = $count;
     $model_UserProfile->testing_count = $testing_count;
     return $model_UserProfile->save();
 }
Ejemplo n.º 2
0
 public function query($params)
 {
     $query = Survey::find();
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $query;
     }
     //         ZCommonFun::print_r_debug($this->attributes);
     $query->andFilterWhere(['id' => $this->id, 'tax' => $this->tax, 'uid' => $this->uid, 'theme' => $this->theme, 'theme_mobile' => $this->theme_mobile, 'is_publish' => $this->is_publish, 'created' => $this->created, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'answer_count' => $this->answer_count, 'visit_count' => $this->visit_count, 'is_public' => $this->is_public, 'is_statistics_public' => $this->is_statistics_public, 'max_answer_count' => $this->max_answer_count, 'is_share_template' => $this->is_share_template, 'answer_total_time' => $this->answer_total_time, 'answer_average_time' => $this->answer_average_time, 'answer_limit_time' => $this->answer_limit_time, 'reward_total' => $this->reward_total, 'reward_average' => $this->reward_average, 'reward_count' => $this->reward_count]);
     $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'pass', $this->pass]);
     return $query;
 }