BusinessStudentTargetUniversity.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class BusinessStudentTargetUniversity extends BusinessActiveRecord
  3. {
  4. public static function model($className = __CLASS__){
  5. return parent::model($className);
  6. }
  7. public function tableName(){
  8. return "student_target_university";
  9. }
  10. public function getStudentTargetList($schoolId,$gradeName,$className,$studentName,$page=1,$pageLimit=15)
  11. {
  12. $offset=($page-1)*$pageLimit;
  13. $pages=array();
  14. $condition = '';
  15. if($gradeName){
  16. $condition .= " and grade_name like '%$gradeName%'";
  17. }
  18. if($className){
  19. $condition .= " and class_name like '%$className%'";
  20. }
  21. if($studentName){
  22. $condition.= " and student_name like '%$studentName%'";
  23. }
  24. $totalQuery=$this->getDbConnection()->createCommand("select count(*) as count from student_target_university where status=1 and school_id={$schoolId}".$condition)->queryRow();
  25. $pages['total']=$totalQuery['count'];
  26. $pages['totalPage']=ceil($totalQuery['count']/$pageLimit);
  27. $pages['page']=$page;
  28. $data = $this->getDbConnection()->createCommand("
  29. select *
  30. from student_target_university
  31. where school_id={$schoolId} and status=1 {$condition}
  32. order by create_time desc
  33. limit {$offset},{$pageLimit}
  34. ")->queryAll();
  35. $return['pages']=$pages;
  36. $return['dataList']=$data;
  37. return $return;
  38. }
  39. }