Exemplo n.º 1
0
 /**
  * 分页查找测试结果
  * @param integer $survey_id
  * @param integer $limit
  * @param integer $offset
  * @param boolean $question 是否查找问题,默认true
  * @param boolean $SurveyResulte_lis_multi 是否多条
  * @return array
  */
 public function findOneSurveyResulte($survey_id, $limit, $offset, $question = true, $SurveyResulte_lis_multi = false)
 {
     $model_SurveyResulte = new SurveyResulte();
     $model_QuestionOptions = new QuestionOptions();
     $condition['s_id'] = $survey_id;
     //结果数量
     $data['count'] = SurveyResulte::find()->where($condition)->orderBy([])->count();
     //结果内容
     $data['SurveyResulte'] = [];
     //问题
     $data['question'] = [];
     if ($data['count'] > 0) {
         $query = $model_SurveyResulte->find()->where($condition)->limit($limit)->offset($offset);
         $model_SurveyResulte = $SurveyResulte_lis_multi ? $query->all() : $query->one();
         $data['SurveyResulte'] = $model_SurveyResulte;
     }
     $data['question'] = $question ? (new Survey())->FindAllQuestionsOptions($survey_id) : [];
     return $data;
 }