12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- /**
- * 业务库教师模型类
- * @author jiangfei
- * @date 2015-09-17 15:00:00
- * @company 上海风车教育有限公司.
- */
- class BusinessTeacher extends BusinessActiveRecord{
-
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return "xb_teacher";
- }
- public function getTeacherInfo($schoolId,$sub = false){
- if(empty($schoolId)) return false;
- $sql = 'SELECT teacher_id,phone_number FROM xb_teacher WHERE school_id='.$schoolId;
- $res = $this->getDbConnection()->createCommand($sql)->queryAll();
- $info = array();
- foreach($res as $key=>$val){
- if($sub) $val['phone_number'] = substr(trim($val['phone_number']),-4);
- $info[$val['phone_number']] = $val['teacher_id'];
- }
- return $info;
- }
- public function getAddTeacherInfo($phoneArr){
- if(empty($phoneArr)) return false;
- $sql = 'SELECT teacher_id,phone_number FROM xb_teacher WHERE phone_number in( '.implode(',',$phoneArr).')';
- $res = $this->getDbConnection()->createCommand($sql)->queryAll();
- $info = array();
- foreach($res as $key=>$val){
- $info[$val['phone_number']] = $val['teacher_id'];
- }
- return $info;
- }
- public function getTeacherIdByNumber($phone,$schoolId){
- if(!$phone || !is_numeric($phone)) return null;
- $sql="select teacher_id,phone_number from xb_teacher where phone_number like '%".$phone."%' and school_id='".$schoolId."'";
- $res = $this->getDbConnection()->createCommand($sql)->queryAll();
- $info = array();
- foreach($res as $key=>$val){
- $info[$val['phone_number']] = $val['teacher_id'];
- }
- return $info;
- }
- }
|