TeacherToClass.php 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * 教师班级关系管理模型类
  4. * @author jiangfei
  5. * @date 2015-08-19 10:30:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. class TeacherToClass extends MyActiveRecord{
  9. public $class_name;
  10. public static function model($className = __CLASS__){
  11. return parent::model($className);
  12. }
  13. public function tableName(){
  14. return 'teacher_class_relation';
  15. }
  16. // 通过教师id获取当前学期执教的班级
  17. public function getClassByTeacher($sid,$tid){
  18. $sql = 'SELECT c.class_name FROM '.$this->tableName().' as tcr left join class as c on c.class_id = tcr.class_id where tcr.semester_id="'.$sid.'" and tcr.teacher_id = "'.$tid.'"';
  19. $list = $this->findAllBySql($sql);
  20. $str = '';
  21. if (empty($list)) {
  22. $str = '暂无';
  23. } else {
  24. foreach ($list as $vv) {
  25. $str.=$vv->class_name.',';
  26. }
  27. $str = rtrim($str,',');
  28. }
  29. return $str;
  30. }
  31. public function getTeacher($sql){
  32. $info = $this->getDbConnection()->createCommand($sql)->queryRow();
  33. return $info;
  34. }
  35. }