getCommandBuilder()->createSqlCommand($sql)->queryAll(); //判断该学生是否第一次下载 否更新download_last_time 是更新download_first_time if($info){ $firstDownloadStudents = $lastDownloadStudents = array(); foreach($info as $val){ if(!$studentIds || ($studentIds && in_array($val['student_id'], $studentIds))){ if(!$val['download_first_time']){ $firstDownloadStudents[] = $val['student_id']; }else{ $lastDownloadStudents[] = $val['student_id']; } } } if($firstDownloadStudents) { $firstDownloadStudents = implode(',', $firstDownloadStudents); $sql = "update product_process_time set download_first_time={$time},download_last_time={$time} where exam_id = {$examId} and product_type = {$type} and student_id in ({$firstDownloadStudents})"; $this->getCommandBuilder()->createSqlCommand($sql)->execute(); } if($lastDownloadStudents){ $lastDownloadStudents = implode(',', $lastDownloadStudents); $sql = "update product_process_time set download_last_time={$time} where exam_id = {$examId} and product_type = {$type} and student_id in ({$lastDownloadStudents})"; $this->getCommandBuilder()->createSqlCommand($sql)->execute(); } } } }