AWhiteList.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class AWhiteList extends BusinessActiveRecord {
  7. public static function model($className = __CLASS__){
  8. return parent::model($className);
  9. }
  10. public function tableName(){
  11. return "assist_white_list";
  12. }
  13. public function primaryKey(){
  14. return array('school_id');
  15. }
  16. public function countSchool($schoolIds=array()){
  17. $sql="select count(*) as count from assist_white_list ";
  18. if($schoolIds){
  19. $sql.=" where school_id in(".implode(',',$schoolIds).")";
  20. }
  21. $data=$this->getDbConnection()->createCommand($sql)->queryRow();
  22. if($data){
  23. return $data['count'];
  24. }
  25. }
  26. public function getList($schoolIds,$page,$pageLimit){
  27. $sql="select * from assist_white_list ";
  28. if($schoolIds){
  29. $sql.=" where school_id in(".implode(',',$schoolIds).")";
  30. }
  31. $offset=($page-1)*$pageLimit;
  32. $sql.=" order by add_time desc ";
  33. $sql.=" limit {$offset},{$pageLimit}";
  34. $data=$this->getDbConnection()->createCommand($sql)->queryAll();
  35. return $data;
  36. }
  37. public function addSchool($schoolId,$schoolName){
  38. if(!$schoolId || !$schoolName) return false;
  39. $sql="replace into assist_white_list(`school_id`,`school_name`,`add_time`) values('".$schoolId."','".$schoolName."','".time()."')";
  40. if($this->getDbConnection()->createCommand($sql)->execute()){
  41. return true;
  42. }
  43. return false;
  44. }
  45. public function getAllSchoolIds(){
  46. $data=$this->getDbConnection()->createCommand("select school_id from assist_white_list")->queryAll();
  47. $schoolIds=array();
  48. if($data){
  49. foreach ($data as $val){
  50. $schoolIds[]=$val['school_id'];
  51. }
  52. }
  53. return $schoolIds;
  54. }
  55. }