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; } }