ZlExamGroup.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class ZlExamGroup 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 eg.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. // $Sql="select count(*) as count from zl_exam_group eg left join `zl_exam` e on eg.zl_exam_group_id=e.zl_exam_group_id ";
  25. $dataCount=$this->sConn->createCommand($Sql." where ".$where ." group by eg.zl_exam_group_id ")->queryAll();
  26. $result['totalCount']=count($dataCount);
  27. $result['pageTotal']=ceil(count($dataCount)/$pagelimit);
  28. $offset=($page-1)*$pagelimit;
  29. $Sql="select eg.zl_exam_group_id,zl_grade,zl_exam_name,zl_exam_date,e.zl_tpl_data,zl_is_display from zl_exam_group eg left join `zl_exam` e on eg.zl_exam_group_id=e.zl_exam_group_id ";
  30. $data=$this->sConn->createCommand($Sql." where ".$where." group by eg.zl_exam_group_id order by zl_create_time desc limit {$offset},{$pagelimit} ")->queryAll();
  31. $result['data']=$data;
  32. return $result;
  33. }
  34. //
  35. public function getExamByExamGroupId($examGroupId){
  36. if(!$examGroupId) return false;
  37. $sql="SELECT eg.zl_exam_group_id,eg.zl_exam_name,eg.zl_exam_type,eg.zl_grade,eg.zl_exam_date,e.zl_class_id,e.zl_exam_id,e.zl_tpl_data,e.zl_subject_ids,zl_grade FROM `zl_exam_group` eg join zl_exam e on e.zl_exam_group_id=eg.zl_exam_group_id where eg.zl_exam_group_id='".$examGroupId."';";
  38. $data=$this->sConn->createCommand($sql)->queryAll();
  39. return $data;
  40. }
  41. /*修改状态*/
  42. public function updateByCondition($data,$condition){
  43. $result=0;
  44. if(!$data || !$condition || !is_array($data) || !is_array($condition)){
  45. return false;
  46. }
  47. $set=array();
  48. $where=array();
  49. foreach($data as $key=>$val){
  50. $set[]="`".$key."` = '".$val."'";
  51. }
  52. foreach ($condition as $key=>$val){
  53. $where[]='`'.$key.'` = '.$val;
  54. }
  55. if($where && $set){
  56. $Sql=" Update `zl_exam_group` ";
  57. $Sql.=" set ".implode(', ',$set);
  58. $Sql.=" where ".implode(' And ',$where);
  59. $result=$this->sConn->createCommand($Sql)->execute();
  60. }
  61. return $result;
  62. }
  63. public function getExamGroupByExamGroupId($examGroupId){
  64. if(!$examGroupId) return false;
  65. $sql="select * from zl_exam_group where zl_exam_group_id='".$examGroupId."'";
  66. return $this->sConn->createCommand($sql)->queryRow();
  67. }
  68. }