123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- /**
- * 教师班级关系管理模型类
- * @author jiangfei
- * @date 2015-08-19 10:30:00
- * @company 上海风车教育有限公司.
- */
- class TeacherToClass extends MyActiveRecord{
-
- public $class_name;
-
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return 'teacher_class_relation';
- }
-
- // 通过教师id获取当前学期执教的班级
- public function getClassByTeacher($sid,$tid){
- $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.'"';
- $list = $this->findAllBySql($sql);
- $str = '';
- if (empty($list)) {
- $str = '暂无';
- } else {
- foreach ($list as $vv) {
- $str.=$vv->class_name.',';
- }
- $str = rtrim($str,',');
- }
- return $str;
- }
- public function getTeacher($sql){
- $info = $this->getDbConnection()->createCommand($sql)->queryRow();
- return $info;
- }
- }
|