1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- /**
- * @author: CeeFee
- * @description: 考试
- */
- class ZlExamGroup extends Model
- {
- function __construct(){
- parent::__construct();
- }
- public function getList($grade,$class,$semester_id,$page,$pagelimit,$is_display=0){
- $result=array();
- $where =" zl_is_display = ".$is_display." ";
- if($class){
- $where.=" And zl_class_id='{$class}' ";
- }
- if($grade){
- $where.=" And zl_grade={$grade} ";
- }
- if($semester_id){
- $where.=" And eg.zl_semester_id={$semester_id} ";
- }
- $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 ";
- // $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 ";
- $dataCount=$this->sConn->createCommand($Sql." where ".$where ." group by eg.zl_exam_group_id ")->queryAll();
- $result['totalCount']=count($dataCount);
- $result['pageTotal']=ceil(count($dataCount)/$pagelimit);
- $offset=($page-1)*$pagelimit;
- $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 ";
- $data=$this->sConn->createCommand($Sql." where ".$where." group by eg.zl_exam_group_id order by zl_create_time desc limit {$offset},{$pagelimit} ")->queryAll();
- $result['data']=$data;
- return $result;
- }
- //
- public function getExamByExamGroupId($examGroupId){
- if(!$examGroupId) return false;
- $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."';";
- $data=$this->sConn->createCommand($sql)->queryAll();
- return $data;
- }
- /*修改状态*/
- public function updateByCondition($data,$condition){
- $result=0;
- if(!$data || !$condition || !is_array($data) || !is_array($condition)){
- return false;
- }
- $set=array();
- $where=array();
- foreach($data as $key=>$val){
- $set[]="`".$key."` = '".$val."'";
- }
- foreach ($condition as $key=>$val){
- $where[]='`'.$key.'` = '.$val;
- }
- if($where && $set){
- $Sql=" Update `zl_exam_group` ";
- $Sql.=" set ".implode(', ',$set);
- $Sql.=" where ".implode(' And ',$where);
- $result=$this->sConn->createCommand($Sql)->execute();
- }
- return $result;
- }
- public function getExamGroupByExamGroupId($examGroupId){
- if(!$examGroupId) return false;
- $sql="select * from zl_exam_group where zl_exam_group_id='".$examGroupId."'";
- return $this->sConn->createCommand($sql)->queryRow();
- }
- }
|