SStudentInfo.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 学期
  5. */
  6. class SStudentInfo extends MyActiveRecord
  7. {
  8. public static function model($className = __CLASS__)
  9. {
  10. return parent::model($className);
  11. }
  12. public function tableName()
  13. {
  14. return 'student_info';
  15. }
  16. public function getStudents($studentIds)
  17. {
  18. $result = array();
  19. if ($studentIds AND is_array($studentIds))
  20. {
  21. $criteria = new CDbCriteria();
  22. $criteria->addCondition("student_id IN (". implode(',', $studentIds) .")");
  23. $result = getAttributes($this->findAll($criteria));
  24. }
  25. return $result;
  26. }
  27. public function getStudentNames($studentIds)
  28. {
  29. $result = array();
  30. $students = $this->getStudents($studentIds);
  31. if ($students)
  32. {
  33. foreach ($students AS $student)
  34. {
  35. $id_str = '';
  36. if($student['id_number']){
  37. $id_str = substr($student['id_number'],-4,4);
  38. }
  39. $result[$student['student_id']] = $student['realname'].$id_str;
  40. }
  41. }
  42. return $result;
  43. }
  44. //分页获取学生数据
  45. public function getStudentsByPages(){
  46. $result = array();
  47. $sql = "select count(0) as count from student_info";
  48. $connect = $this->getDbConnection();
  49. $countArr = $connect->createCommand($sql)->queryRow();
  50. if($countArr && $countArr['count']){
  51. $count = $countArr['count'];
  52. $limit = 10000;
  53. $page = ceil($count/$limit);
  54. $_sql = "select * from student_info";
  55. for($a = 1;$a <= $page;$a++){
  56. $offset = ($a - 1)*$limit;
  57. $_sqls = $_sql." limit {$offset},{$limit}";
  58. $data = $connect->createCommand($_sqls)->queryAll();
  59. foreach($data as $k=>$v){
  60. $result['school_student_info'][$v['student_id']] = $v;
  61. $result['school_student_names'][$v['student_id']] = $v['realname'];
  62. }
  63. unset($data);
  64. }
  65. }
  66. return $result;
  67. }
  68. public function getStudentLevelList($grade,$classId,$studentName,$semesterId, $page=1,$pageLimit=15)
  69. {
  70. $offset=($page-1)*$pageLimit;
  71. $pages=array();
  72. $condition = '';
  73. $condition.= "and c.semester_id = '$semesterId'";
  74. if($grade){
  75. $condition .= "and c.grade = $grade";
  76. }
  77. if($classId){
  78. $condition .= " and r.class_id ='{$classId}'";
  79. }
  80. if($studentName){
  81. $condition.= " and i.realname like '%$studentName%'";
  82. }
  83. $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();
  84. $pages['total']=$totalQuery['count'];
  85. $pages['totalPage']=ceil($totalQuery['count']/$pageLimit);
  86. $pages['page']=$page;
  87. $data = $this->getDbConnection()->createCommand("
  88. 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
  89. INNER JOIN class c on r.class_id=c.class_id INNER JOIN student_info i on i.student_id=r.student_id
  90. WHERE r.`status`=0 {$condition}
  91. group by r.student_id
  92. limit {$offset},{$pageLimit}
  93. ")->queryAll();
  94. $return['pages']=$pages;
  95. $return['dataList']=$data;
  96. return $return;
  97. }
  98. }