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; } }