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