Esempio n. 1
0
 /**
  * 保存数据
  * @param array $data
  * @return Ambigous <multitype:, multitype:boolean unknown mixed >
  */
 public function saveData($data)
 {
     $data = get_array_data($data, 'name,isSuper,auth', 'id');
     $data['auth'] = serialize($data['auth']);
     $data['isSuper'] = $data['isSuper'] == 1 ? 1 : 0;
     if ($this->create($data)) {
         if (empty($data['id'])) {
             $id = $this->add();
         } else {
             $id = $this->save();
         }
         $this->updateCache();
         return result_data(1, '数据保存成功!', array('id' => $id));
     } else {
         return result_data(0, $this->getError());
     }
 }
Esempio n. 2
0
 /**
  * 保存数据
  * @param array $data
  */
 public function saveData($data)
 {
     $data = get_array_data($data, 'name,status,password,roleId', 'id,realName');
     if (!empty($data['password'])) {
         $data['password'] = md5($data['password']);
     } else {
         if (!empty($data['id'])) {
             unset($data['password']);
         }
         //编辑时无设置新密码时取消更新此项
     }
     if ($this->create($data)) {
         if (empty($data['id'])) {
             $id = $this->add();
         } else {
             $id = $this->save();
         }
         return result_data(1, '数据保存成功!', array('id' => $id));
     } else {
         return result_data(0, $this->getError());
     }
 }