ZlExam.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class ZlExam extends Model
  7. {
  8. function __construct(){
  9. parent::__construct();
  10. }
  11. public function getList($grade,$class,$semester_id,$page,$pagelimit,$is_display=0){
  12. $result=array();
  13. $where =" zl_is_display = ".$is_display." ";
  14. if($class){
  15. $where.=" And zl_class_id='{$class}' ";
  16. }
  17. if($grade){
  18. $where.=" And zl_grade={$grade} ";
  19. }
  20. if($semester_id){
  21. $where.=" And zl_semester_id={$semester_id} ";
  22. }
  23. $Sql="select count(0) as count from zl_exam_group eg join `zl_exam` e on eg.zl_exam_group_id=e.zl_exam_group_id ";
  24. $dataCount=$this->sConn->createCommand($Sql." where ".$where)->queryRow();
  25. $result['totalCount']=$dataCount['count'];
  26. $result['pageTotal']=ceil($dataCount['count']/$pagelimit);
  27. $offset=($page-1)*$pagelimit;
  28. $Sql="select zl_exam_group_id,zl_grade,zl_exam_name,zl_exam_date,e.zl_tpl_data from zl_exam_group eg join `zl_exam` e on eg.zl_exam_group_id=e.zl_exam_group_id ";
  29. $data=$this->sConn->createCommand($Sql." where ".$where." order by zl_create_time desc limit {$offset},{$pagelimit} ")->queryAll();
  30. $result['data']=$data;
  31. return $result;
  32. }
  33. public function getExamByExamGroupId($examGroupId){
  34. if(!$examGroupId) return false;
  35. $sql="select * from zl_exam where zl_exam_group_id='".$examGroupId."'";
  36. return $this->sConn->createCommand($sql)->queryAll();
  37. }
  38. public function getExamByExamId($examId){
  39. if(!$examId) return false;
  40. $sql="select * from zl_exam where zl_exam_id='".$examId."'";
  41. return $this->sConn->createCommand($sql)->queryRow();
  42. }
  43. }