ZlStudentExamRelation.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class ZlStudentExamRelation extends Model
  7. {
  8. function __construct(){
  9. parent::__construct();
  10. }
  11. public function getCountStudentByExamGroupId($exmGroupId,$examId=0){
  12. if(!$exmGroupId) return 0;
  13. $sql="select count(0) as count from `zl_student_exam_relation` where zl_exam_group_id = '".$exmGroupId."'";
  14. if($examId){
  15. $sql.=" and zl_exam_id='".$examId."'";
  16. }
  17. $sql.=" and zl_is_del=0";
  18. $data=$this->sConn->createCommand($sql)->queryRow();
  19. if($data){
  20. return $data['count'];
  21. }
  22. return 0;
  23. }
  24. public function getStudentByExamId($examId=0){
  25. if(!$examId) return 0;
  26. $sql="select ser.zl_student_id,ser.zl_exam_group_id,ser.zl_class_id,ser.zl_student_card,ser.zl_school_student_card,sers.zl_subject_id from `zl_student_exam_relation` ser ";
  27. $sql.="left join zl_student_exam_rs sers on ser.zl_exam_id=sers.zl_exam_id and ser.zl_student_id=sers.zl_student_id ";
  28. $sql.=" where ser.zl_exam_id = '".$examId."' ";
  29. // $sql="select zl_student_id,zl_exam_group_id,zl_class_id,zl_student_card,zl_school_student_card from `zl_student_exam_relation` where zl_exam_id = '".$examId."'";
  30. $sql.=" and zl_is_del=0 group by ser.zl_student_id";
  31. $data=$this->sConn->createCommand($sql)->queryAll();
  32. return $data;
  33. }
  34. //删除学生
  35. public function delAllStudentByExamId($examId){
  36. if(!$examId) return false;
  37. $sql="update zl_student_exam_relation set zl_is_del=1 where zl_exam_id='".$examId."'";
  38. return $this->sConn->createCommand($sql)->execute();
  39. }
  40. //删除学生
  41. public function delAllStudentByExamGroupId($examGroupId){
  42. if(!$examGroupId) return false;
  43. $sql="update zl_student_exam_relation set zl_is_del=1 where zl_exam_group_id='".$examGroupId."'";
  44. return $this->sConn->createCommand($sql)->execute();
  45. }
  46. }