123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * @author: CeeFee
- * @description: 考试
- */
- class AWhiteList extends BusinessActiveRecord {
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return "assist_white_list";
- }
- public function primaryKey(){
- return array('school_id');
- }
- public function countSchool($schoolIds=array()){
- $sql="select count(*) as count from assist_white_list ";
- if($schoolIds){
- $sql.=" where school_id in(".implode(',',$schoolIds).")";
- }
- $data=$this->getDbConnection()->createCommand($sql)->queryRow();
- if($data){
- return $data['count'];
- }
- }
- public function getList($schoolIds,$page,$pageLimit){
- $sql="select * from assist_white_list ";
- if($schoolIds){
- $sql.=" where school_id in(".implode(',',$schoolIds).")";
- }
- $offset=($page-1)*$pageLimit;
- $sql.=" order by add_time desc ";
- $sql.=" limit {$offset},{$pageLimit}";
- $data=$this->getDbConnection()->createCommand($sql)->queryAll();
- return $data;
- }
- public function addSchool($schoolId,$schoolName){
- if(!$schoolId || !$schoolName) return false;
- $sql="replace into assist_white_list(`school_id`,`school_name`,`add_time`) values('".$schoolId."','".$schoolName."','".time()."')";
- if($this->getDbConnection()->createCommand($sql)->execute()){
- return true;
- }
- return false;
- }
- public function getAllSchoolIds(){
- $data=$this->getDbConnection()->createCommand("select school_id from assist_white_list")->queryAll();
- $schoolIds=array();
- if($data){
- foreach ($data as $val){
- $schoolIds[]=$val['school_id'];
- }
- }
- return $schoolIds;
- }
- }
|