123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- /**
- * @author: CeeFee
- * @description: 班级
- */
- class SStudentClassRelation extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
-
- public function tableName()
- {
- return 'student_class_relation';
- }
-
- public function getRelationsByClassId_Status_0($classId)
- {
- $result = array();
-
- if ($classId AND is_numeric($classId))
- {
- $criteria = new CDbCriteria();
- $criteria->addCondition("class_id = '". $classId ."' AND status = '0'");
-
- $result = $this->findAll($criteria);
- }
-
- return $result;
- }
-
- public function getRelationsByClassId_Status_0_count($classId)
- {
- $result = array();
-
- if ($classId AND is_numeric($classId))
- {
- $criteria = new CDbCriteria();
- $criteria->addCondition("class_id = '". $classId ."' AND status = '0'");
-
- $result = $this->count($criteria);
- }
-
- return $result;
- }
-
- public function getRelationsByClassIds_Status_0($classIds)
- {
- $result = array();
-
- if ($classIds AND is_array($classIds))
- {
- $criteria = new CDbCriteria();
- $criteria->addCondition("class_id IN (". implode(',', $classIds) .") AND status = '0'");
-
- $result = $this->findAll($criteria);
- }
-
- return $result;
- }
-
- public function getStudentIdsByClassId_Status_0($classId)
- {
- $relations = $this->getRelationsByClassId_Status_0($classId);
- $result = array();
-
- if ($relations)
- {
- foreach ($relations AS $relation)
- {
- $result[] = $relation['student_id'];
- }
- }
-
- return $result ? array_unique($result) : $result;
- }
-
- public function getStudentNosByClassId_Status_0($classId)
- {
- $relations = $this->getRelationsByClassId_Status_0($classId);
- $result = array();
-
- if ($relations)
- {
- foreach ($relations AS $relation)
- {
- $result[$relation['student_id']] = $relation['userno'];
- }
- }
-
- return $result;
- }
-
- public function getClassStudentIdsByClassIds_Status_0($classIds)
- {
- $relations = $this->getRelationsByClassIds_Status_0($classIds);
- $result = array();
-
- if ($relations)
- {
- foreach ($relations AS $relation)
- {
- if ( ! isset($result[$relation['class_id']]))
- {
- $result[$relation['class_id']] = array();
- }
-
- $result[$relation['class_id']][] = $relation['student_id'];
- }
- }
-
- return $result;
- }
- public function getStudentInfoByClassId($classId,$studentName='')
- {
- if($studentName){
- $sql = "SELECT s.realname,p.student_id,p.serial_number
- FROM student_class_relation as p
- LEFT JOIN student_info as s on s.student_id = p.student_id
- WHERE p.class_id = {$classId} AND p.status = 0 AND s.realname like '%".$studentName."%'
- ";
- }else{
- $sql = "SELECT s.realname,p.student_id,p.serial_number
- FROM student_class_relation as p
- LEFT JOIN student_info as s on s.student_id = p.student_id
- WHERE p.class_id = {$classId} AND p.status = 0
- ";
- }
- $result = $this->getDbConnection()->createCommand($sql)->queryAll();
- return $result;
- }
- public function getStudentInfoByClassIds($classIds)
- {
- $sql = "SELECT s.realname,p.student_id,p.class_id
- FROM student_class_relation as p
- LEFT JOIN student_info as s on s.student_id = p.student_id
- WHERE p.class_id IN {$classIds} AND p.status = 0
- ";
- $result = $this->getDbConnection()->createCommand($sql)->queryAll();
- return $result;
- }
-
-
- //分页获取学生数据
- public function getStudentsByPages($class_ids){
- $result = array();
- $sql = "select count(0) as count from student_class_relation where class_id in ('{$class_ids}')";
- $connect = $this->getDbConnection();
- $countArr = $connect->createCommand($sql)->queryRow();
- return $countArr;
- if($countArr && $countArr['count']){
- $count = $countArr['count'];
- $limit = 10000;
- $page = ceil($count/$limit);
-
- $_sql = "select * from student_info";
- for($a = 1;$a <= $page;$a++){
- $offset = ($a - 1)*$limit;
- $_sqls = $_sql." limit {$offset},{$limit}";
- $data = $connect->createCommand($_sqls)->queryAll();
- foreach($data as $k=>$v){
- $result['school_student_info'][$v['student_id']] = $v;
- $result['$school_student_names'][$v['student_id']] = $v['realname'];
- }
- unset($data);
- }
- }
- return $result;
- }
-
-
-
- }
|