123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /**
- * 学员详细信息模型类
- * @author jiangfei
- * @date 2015-07-20 19:30:00
- * @company 上海风车教育有限公司.
- */
- class StudentInfo extends MyActiveRecord{
-
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return 'student_info';
- }
-
-
- // 教练列表
- public function getUserList($class_id=array(),$realname='',$sort=''){
-
- $data = array();
- $criteria = new CDbCriteria();
- //if (!empty($class_id)) {
- $criteria->addInCondition('class_id', $class_id);
- //}
-
- !$realname || $criteria->addSearchCondition('realname', $realname);
- $total = $this->count($criteria);
- $pager = new CPagination($total);
- if (empty($sort)) {
- $criteria->order = 'student_id desc';
- } else {
- if ($sort == 1) {
- $criteria->order = '(userno+0) asc';
- } else {
- $criteria->order = '(userno+0) desc';
- }
- }
-
- $pager->pageSize = 20;
- $pager->applyLimit($criteria);
- $data['result']=$this->findAll($criteria);
- $data['page']=$pager;
- $data['page_total']= $total;
- unset($criteria);
- return $data;
- }
-
- // 获取学员真实姓名
- public function getRealname($stid){
- $res = $this->find('student_id=:stid',array(':stid'=>$stid));
- $str = '';
- if (!empty($res)) {
- $str = $res->realname;
- }
- unset($res);
- return $str;
- }
-
- // 获取学员所属班级id
- public function getClassId($stid){
- $res = $this->find('student_id=:stid',array(':stid'=>$stid));
- $str = '';
- if (!empty($res)) {
- $str = $res->class_id;
- }
- unset($res);
- return $str;
- }
- /**
- * 获取班级的学生
- * 作者:刘红伟
- * 时间:2016-07-19
- * @param $class_id
- */
- public function getStudentByClassId($class_id)
- {
- $student_data = $this->findAll('class_id=:class_id',array(':class_id'=>$class_id));
- if($student_data)
- {
- return $student_data;
- }
- return false;
- }
-
- public function getStudentInClassId($class_ids)
- {
- $student_data=false;
- if($class_ids){
- $criteria = new CDbCriteria();
- if(!is_array($class_ids)){
- $criteria->addInCondition('class_id', explode("," ,$class_ids));
- }else{
- $criteria->addInCondition('class_id', $class_ids);
- }
- $student_data = $this->findAll($criteria);
-
- }
-
- if($student_data)
- {
- return $student_data;
- }
- return false;
- }
- }
|