public static function save(Application_Model_O_GlobalConsultationApply $obj, $extra = '') { if (!$obj->getModifiedFields()) { return $obj; } foreach ($obj->getModifiedFields() as $key => $value) { $field = self::$fields[strtolower($key)]; if ($field) { $data[$field] = $value; } } if (!$obj->getId()) { $obj->setId(self::getDbTable()->insert($data, $extra)); $obj->setNew(false); } else { self::getDbTable()->update($data, array('id = ?' => $obj->getId())); } return $obj; }
public function applyAction() { $category = $this->_getParam('category'); $department = $this->_getParam('department'); $email = $this->_getParam('email'); $mobile = $this->_getParam('mobile'); $age = $this->_getParam('age'); $sex = $this->_getParam('sex'); $location = $this->_getParam('location'); $treatment_time = $this->_getParam('treatment_time'); $opinion = $this->_getParam('opinion'); $report = $this->_getParam('report'); $apply = new Application_Model_O_GlobalConsultationApply(); $apply->setDepartment_category_id($category)->setDepartment_id($department)->setEmail($email)->setMobile($mobile)->setAge($age)->setSex($sex)->setLocation($location)->setTreatment_time($treatment_time)->setOpinion($opinion)->setCtime(date('Y-m-d H:i:s')); try { $out['errno'] = '0'; $apply->save(); //保存病例报告 $adapter = new Zend_File_Transfer_Adapter_Http(); $wrdir = Yy_Utils::getWriteDir(); $adapter->setDestination($wrdir); if (!$adapter->receive()) { $messages = $adapter->getMessages(); //echo implode("\n", $messages); } $filename = $adapter->getFileName(); if (is_string($filename)) { $handle = fopen($filename, 'rb'); $report = addslashes(fread($handle, filesize($filename))); fclose($handle); Application_Model_M_GlobalConsultationApply::updateReport($apply->getId(), $report); } } catch (Zend_Db_Exception $e) { $out['errno'] = '1'; //echo $e->getMessage(); } $out['msg'] = Yy_ErrMsg_Diagnosis::getMsg('apply', $out['errno']); Yy_Utils::jsonOut($out); }