$val){ $values[]="('".$key."','".$val."')"; } $sql.=implode(',',$values); if($this->getDbConnection()->createCommand($sql)->execute()){ return true; } return false; } //校验科目是否已使用 public function checkSubjectUsed($subjectId){ if(!$subjectId){ return false; } //查询绑定教师 $sql="select teacher_id from teacher where subjects ='{$subjectId}' limit 1"; $teacher=$this->getDbConnection()->createCommand($sql)->queryRow(); if($teacher){ return true; } //查询班级 $sql="select class_id from class_subject_relation where subject_id ='{$subjectId}' limit 1"; $classTeacher=$this->getDbConnection()->createCommand($sql)->queryRow(); if($classTeacher){ return true; } //走班设置 $sql="select subject_id from classified where subject_id ='{$subjectId}' limit 1"; $classified=$this->getDbConnection()->createCommand($sql)->queryRow(); if($classified){ return true; } //考试 $sql="select exam_id from exam where subject_id ='{$subjectId}' limit 1"; $exam=$this->getDbConnection()->createCommand($sql)->queryRow(); if($exam){ return true; } //知了考试 $sql="select zl_exam_id from zl_exam where find_in_set('".$subjectId."',zl_subject_ids) limit 1"; $exam=$this->getDbConnection()->createCommand($sql)->queryRow(); if($exam){ return true; } return false; } //删除自定义科目 public function delExtendSubject($subjectId){ if(!$subjectId){ return false; } if($this->getDbConnection()->createCommand("delete from extend_subject where subject_id='{$subjectId}'")->execute()){ return true; } return false; } }