semester["id"]}'")); $condition = $this->condition($condition); $orderBy = $this->orderBy($orderBy); $handle = $this->sConn->createCommand(" select m.micro_id,m.name,c.grade,c.class_id,c.class_name from math_micro_setting m join class c on m.class_id= c.class_id {$condition} group by m.micro_id {$orderBy} ")->query(); $rs = $this->paging($this->sConn, $handle, $pageSize); if ($rs['rs']) { foreach ($rs['rs'] as $k => $v) { $rs['rs'][$k]['totalCount'] = 0; $rs['rs'][$k]['pdfCount'] = 0; $rs['rs'][$k]['isDown'] = 0; $rs['rs'][$k]['downTime'] = ''; $micro_id = $v['micro_id']; $sql = "select COUNT(student_id) AS totalCount,SUM(CASE WHEN is_micro_pdf = 1 THEN 1 ELSE 0 END) AS pdfCount from math_micro_student where micro_id = '{$micro_id}'"; $countArr = $this->sConn->createCommand($sql)->queryRow(); if ($countArr) { $rs['rs'][$k]['totalCount'] = isset($countArr['totalCount']) ? $countArr['totalCount'] : 0; $rs['rs'][$k]['pdfCount'] = isset($countArr['pdfCount']) ? $countArr['pdfCount'] : 0; } $sql = "select micro_download_time from math_micro_student where micro_id = '{$micro_id}' and is_micro_download = 1 order by micro_download_time desc limit 1"; $isDownArr = $this->sConn->createCommand($sql)->queryRow(); if ($isDownArr) { $rs['rs'][$k]['isDown'] = 1; $rs['rs'][$k]['downTime'] = isset($isDownArr['micro_download_time']) ? date("Y-m-d H:i", $isDownArr['micro_download_time']) : ''; } } } return $rs; } }