Пример #1
0
 public static function save(Application_Model_O_Doctor $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;
 }
Пример #2
0
 public function registerAction()
 {
     $name = $this->_getParam('name');
     $avatar = $this->_getParam('avatar');
     $sex = $this->_getParam('sex');
     $birthday = $this->_getParam('birthday');
     $email = $this->_getParam('email');
     $passwd = $this->_getParam('passwd');
     $phone = $this->_getParam('phone');
     $department = $this->_getParam('department');
     $city = $this->_getParam('city');
     //$certified  = $this->_getParam('certified');
     $special = $this->_getParam('special');
     $country = $this->_getParam('country');
     $introduction = $this->_getParam('introduction');
     $hospital = $this->_getParam('hospital');
     $area = $this->_getParam('area');
     $qualification = $this->_getParam('qualification');
     if (!$passwd) {
         $out['errno'] = '3';
         $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']);
         Yy_Utils::jsonOut($out);
         return;
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     if ($validatorEmail->isValid($email)) {
         $bool = Application_Model_M_Doctor::fetchByEmail($email);
         if ($bool) {
             //已注册
             $out['errno'] = '1';
         } else {
             $out['errno'] = '0';
             $doctor = new Application_Model_O_Doctor();
             $doctor->setName($name)->setSex($sex)->setBirthday($birthday)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartment($department)->setCity($city)->setSpecial($special)->setCountry($country)->setIntroduction($introduction)->setHospital($hospital)->setArea($area)->setQualification($qualification)->setCtime(date('Y-m-d H:i:s'));
             $certified = ceil(count($doctor->getModifiedFields()) / 3);
             $doctor->setCertified($certified);
             $doctor->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');
                 $avatar = addslashes(fread($handle, filesize($filename)));
                 fclose($handle);
                 Application_Model_M_Doctor::updateAvatar($doctor->getId(), $avatar);
             }
         }
     } else {
         $out['errno'] = '2';
     }
     $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']);
     Yy_Utils::jsonOut($out);
 }