BusinessTeacher.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * 业务库教师模型类
  4. * @author jiangfei
  5. * @date 2015-09-17 15:00:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. class BusinessTeacher extends BusinessActiveRecord{
  9. public static function model($className = __CLASS__){
  10. return parent::model($className);
  11. }
  12. public function tableName(){
  13. return "xb_teacher";
  14. }
  15. public function getTeacherInfo($schoolId,$sub = false){
  16. if(empty($schoolId)) return false;
  17. $sql = 'SELECT teacher_id,phone_number FROM xb_teacher WHERE school_id='.$schoolId;
  18. $res = $this->getDbConnection()->createCommand($sql)->queryAll();
  19. $info = array();
  20. foreach($res as $key=>$val){
  21. if($sub) $val['phone_number'] = substr(trim($val['phone_number']),-4);
  22. $info[$val['phone_number']] = $val['teacher_id'];
  23. }
  24. return $info;
  25. }
  26. public function getAddTeacherInfo($phoneArr){
  27. if(empty($phoneArr)) return false;
  28. $sql = 'SELECT teacher_id,phone_number FROM xb_teacher WHERE phone_number in( '.implode(',',$phoneArr).')';
  29. $res = $this->getDbConnection()->createCommand($sql)->queryAll();
  30. $info = array();
  31. foreach($res as $key=>$val){
  32. $info[$val['phone_number']] = $val['teacher_id'];
  33. }
  34. return $info;
  35. }
  36. public function getTeacherIdByNumber($phone,$schoolId){
  37. if(!$phone || !is_numeric($phone)) return null;
  38. $sql="select teacher_id,phone_number from xb_teacher where phone_number like '%".$phone."%' and school_id='".$schoolId."'";
  39. $res = $this->getDbConnection()->createCommand($sql)->queryAll();
  40. $info = array();
  41. foreach($res as $key=>$val){
  42. $info[$val['phone_number']] = $val['teacher_id'];
  43. }
  44. return $info;
  45. }
  46. }