StudentInfo.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * 学员详细信息模型类
  4. * @author jiangfei
  5. * @date 2015-07-20 19:30:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. class StudentInfo extends MyActiveRecord{
  9. public static function model($className = __CLASS__){
  10. return parent::model($className);
  11. }
  12. public function tableName(){
  13. return 'student_info';
  14. }
  15. // 教练列表
  16. public function getUserList($class_id=array(),$realname='',$sort=''){
  17. $data = array();
  18. $criteria = new CDbCriteria();
  19. //if (!empty($class_id)) {
  20. $criteria->addInCondition('class_id', $class_id);
  21. //}
  22. !$realname || $criteria->addSearchCondition('realname', $realname);
  23. $total = $this->count($criteria);
  24. $pager = new CPagination($total);
  25. if (empty($sort)) {
  26. $criteria->order = 'student_id desc';
  27. } else {
  28. if ($sort == 1) {
  29. $criteria->order = '(userno+0) asc';
  30. } else {
  31. $criteria->order = '(userno+0) desc';
  32. }
  33. }
  34. $pager->pageSize = 20;
  35. $pager->applyLimit($criteria);
  36. $data['result']=$this->findAll($criteria);
  37. $data['page']=$pager;
  38. $data['page_total']= $total;
  39. unset($criteria);
  40. return $data;
  41. }
  42. // 获取学员真实姓名
  43. public function getRealname($stid){
  44. $res = $this->find('student_id=:stid',array(':stid'=>$stid));
  45. $str = '';
  46. if (!empty($res)) {
  47. $str = $res->realname;
  48. }
  49. unset($res);
  50. return $str;
  51. }
  52. // 获取学员所属班级id
  53. public function getClassId($stid){
  54. $res = $this->find('student_id=:stid',array(':stid'=>$stid));
  55. $str = '';
  56. if (!empty($res)) {
  57. $str = $res->class_id;
  58. }
  59. unset($res);
  60. return $str;
  61. }
  62. /**
  63. * 获取班级的学生
  64. * 作者:刘红伟
  65. * 时间:2016-07-19
  66. * @param $class_id
  67. */
  68. public function getStudentByClassId($class_id)
  69. {
  70. $student_data = $this->findAll('class_id=:class_id',array(':class_id'=>$class_id));
  71. if($student_data)
  72. {
  73. return $student_data;
  74. }
  75. return false;
  76. }
  77. public function getStudentInClassId($class_ids)
  78. {
  79. $student_data=false;
  80. if($class_ids){
  81. $criteria = new CDbCriteria();
  82. if(!is_array($class_ids)){
  83. $criteria->addInCondition('class_id', explode("," ,$class_ids));
  84. }else{
  85. $criteria->addInCondition('class_id', $class_ids);
  86. }
  87. $student_data = $this->findAll($criteria);
  88. }
  89. if($student_data)
  90. {
  91. return $student_data;
  92. }
  93. return false;
  94. }
  95. }