123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- /**
- * @author: CeeFee
- * @description: 学期
- */
- class SStudentInfo extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
-
- public function tableName()
- {
- return 'student_info';
- }
-
- public function getStudents($studentIds)
- {
- $result = array();
-
- if ($studentIds AND is_array($studentIds))
- {
- $criteria = new CDbCriteria();
- $criteria->addCondition("student_id IN (". implode(',', $studentIds) .")");
-
- $result = getAttributes($this->findAll($criteria));
- }
-
- return $result;
- }
-
- public function getStudentNames($studentIds)
- {
- $result = array();
- $students = $this->getStudents($studentIds);
-
- if ($students)
- {
- foreach ($students AS $student)
- {
- $id_str = '';
- if($student['id_number']){
- $id_str = substr($student['id_number'],-4,4);
- }
- $result[$student['student_id']] = $student['realname'].$id_str;
- }
- }
-
- return $result;
- }
-
-
- //分页获取学生数据
- public function getStudentsByPages(){
- $result = array();
- $sql = "select count(0) as count from student_info";
- $connect = $this->getDbConnection();
- $countArr = $connect->createCommand($sql)->queryRow();
- if($countArr && $countArr['count']){
- $count = $countArr['count'];
- $limit = 10000;
- $page = ceil($count/$limit);
-
- $_sql = "select * from student_info";
- for($a = 1;$a <= $page;$a++){
- $offset = ($a - 1)*$limit;
- $_sqls = $_sql." limit {$offset},{$limit}";
- $data = $connect->createCommand($_sqls)->queryAll();
- foreach($data as $k=>$v){
- $result['school_student_info'][$v['student_id']] = $v;
- $result['school_student_names'][$v['student_id']] = $v['realname'];
- }
- unset($data);
- }
- }
- return $result;
- }
- public function getStudentLevelList($grade,$classId,$studentName,$semesterId, $page=1,$pageLimit=15)
- {
- $offset=($page-1)*$pageLimit;
- $pages=array();
- $condition = '';
- $condition.= "and c.semester_id = '$semesterId'";
- if($grade){
- $condition .= "and c.grade = $grade";
- }
- if($classId){
- $condition .= " and r.class_id ='{$classId}'";
- }
- if($studentName){
- $condition.= " and i.realname like '%$studentName%'";
- }
- $totalQuery=$this->getDbConnection()->createCommand("select COUNT(DISTINCT r.student_id) as `count` from student_class_relation r INNER JOIN class c on r.class_id=c.class_id INNER JOIN student_info i on i.student_id=r.student_id WHERE r.`status`=0 ".$condition)->queryRow();
- $pages['total']=$totalQuery['count'];
- $pages['totalPage']=ceil($totalQuery['count']/$pageLimit);
- $pages['page']=$page;
- $data = $this->getDbConnection()->createCommand("
- select r.student_id,c.class_id,c.class_name,c.grade,i.realname,i.english_level_one,i.english_level_artificial from student_class_relation r
- INNER JOIN class c on r.class_id=c.class_id INNER JOIN student_info i on i.student_id=r.student_id
- WHERE r.`status`=0 {$condition}
- group by r.student_id
- limit {$offset},{$pageLimit}
- ")->queryAll();
- $return['pages']=$pages;
- $return['dataList']=$data;
- return $return;
- }
- }
|