public function readline_examinee($sheet, $project_id, $number, $i) { $examinee = new Examinee(); foreach ($this->excel_col as $key => $value) { $examinee->{$value} = self::filter($sheet->getCell($key . $i)->getValue()); } $sex = self::filter($sheet->getCell($key . $i)->getValue()); if ($sex == '男' || $sex == 1) { $examinee->sex = 1; } else { $examinee->sex = 1; } $education = array(); $work = array(); $this->readother_examinee($sheet, $education, $this->edu_name, $i); $this->readother_examinee($sheet, $work, $this->work_name, $i); $examinee->other = json_encode(array('education' => $education, 'work' => $work)); $examinee->number = date('y') . sprintf("%02d", $project_id) . sprintf("%04d", $number); $examinee->password = $this->random_string(); $examinee->project_id = $project_id; if (!$examinee->save()) { foreach ($examinee->getMessages() as $message) { throw new Exception($message); } } }