businessDb->createCommand($sql)->queryAll(); foreach ($schoolData as $val){ $schoolIds[]=$val['school_id']; } return $schoolIds; } public function countSchool($condition){ $sql="select count(*) as count from school "; if($condition){ $sql.=" where ".implode(' and ',$condition); } $data=$this->getDbConnection()->createCommand($sql)->queryRow(); if($data){ return $data['count']; } } public function getList($condition,$page,$pageLimit){ $sql="select school_id,school_name,province_id,city_id,area_id from school "; if($condition){ $sql.=" where ".implode(' and ',$condition); } $sql.=" order by school_id asc "; $offset=($page-1)*$pageLimit; $sql.=" limit {$offset},{$pageLimit}"; $data=$this->getDbConnection()->createCommand($sql)->queryAll(); return $data; } //更新学校学生设备权限 public function updateLoginPermission($schoolId,$permission){ $result = 0; $sql="select school_id,is_login_permission from school where school_id = '{$schoolId}' and is_login_permission = '{$permission}'"; $schoolData=$this->getDbConnection()->createCommand($sql)->queryRow(); if(!$schoolData){ $sql = "update school set is_login_permission='{$permission}' where school_id = {$schoolId}"; $is_edit=$this->getDbConnection()->createCommand($sql)->execute(); if($is_edit){ $result = $permission; }else{ $result = $schoolData['is_login_permission']; } }else{ $result = $schoolData['is_login_permission']; } return $result; } }