Blacklist.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * 黑名单管理模型类
  4. * @author li
  5. * @date 2020-04-09 19:30:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. // class Exam extends CActiveRecord{
  9. class Blacklist extends MyActiveRecord{
  10. public static function model($className = __CLASS__){
  11. return parent::model($className);
  12. }
  13. public function tableName(){
  14. return 'blacklist';
  15. }
  16. public function getExamList($arr,$page=1,$pageLimit){
  17. $sql="select exam_id,name,type,subject_id,class_name,class_type,grade,exam_create_time,exam_date from blacklist ";
  18. $countSql="select count(*) as count from blacklist ";
  19. if($arr){
  20. $countSql.=" where ".implode(' and ',$arr);
  21. $sql.=" where ".implode(' and ',$arr);
  22. }
  23. $countData=$this->getCommandBuilder()->createSqlCommand($countSql)->queryRow();
  24. $result=array(
  25. 'total'=>$countData['count'],
  26. 'pageTotal'=>ceil($countData['count']/$pageLimit),
  27. 'page'=>$page
  28. );
  29. $offset=($page-1)*$pageLimit;
  30. $sql.=" order by exam_group_id asc,class_id asc limit ".$offset.",".$pageLimit;
  31. $data=$countData=$this->getCommandBuilder()->createSqlCommand($sql)->queryAll();
  32. $result['dataList']=$data;
  33. return $result;
  34. }
  35. }