public function ajaxAddProblemAction() { $problemJson = Request::getPOST('problem-json'); $problemList = json_decode($problemJson); if (empty($problemList)) { $this->renderError('参数错误2!'); } $dataList = array(); foreach ($problemList as $problemInfo) { $problemInfo = (array) $problemInfo; // 如果title为空,那么不插入 if (empty($problemInfo['problem_id']) || empty($problemInfo['problem_code']) || empty($problemInfo['title'])) { continue; } $data = array(); $data['remote'] = $problemInfo['remote']; $data['problem_id'] = $problemInfo['problem_id']; $data['problem_code'] = $problemInfo['problem_code']; $data['title'] = $problemInfo['title']; $data['source'] = $problemInfo['source']; $data['user_id'] = $this->loginUserInfo['id']; $data['hidden'] = empty($data['title']) ? 1 : 0; $dataList[] = $data; } OjProblemInterface::insertAll($dataList); $this->renderAjax(0); }