當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::setAttributes方法代碼示例

本文整理匯總了PHP中common\models\User::setAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setAttributes方法的具體用法?PHP User::setAttributes怎麽用?PHP User::setAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common\models\User的用法示例。


在下文中一共展示了User::setAttributes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * 更新用戶信息
  * @return boolean
  */
 public function update(User $user)
 {
     $pre_username = $user->username;
     $user->setAttributes($this->attributes);
     if ($pre_username != $user->wangwang) {
         $user->setAttribute("username", $pre_username);
     }
     return $user->update();
 }
開發者ID:wxzuan,項目名稱:wxzuan,代碼行數:13,代碼來源:UserInfoForm.php

示例2: actionUser

 public function actionUser()
 {
     $usersData = \yii::$app->oldcmsdb->createCommand("SELECT * FROM tc_author_master WHERE author_id not in (40)")->query();
     \yii::$app->db->createCommand("delete from tc_user WHERE Id not in (40)")->query();
     while ($row = $usersData->read()) {
         $attributes = array('Id' => $row['author_id'], 'username' => $row['author_username'], 'email' => $row['author_email'], 'status' => $row['author_status'] == 1 ? 1 : 0, 'createdBy' => 40, 'groupId' => 8, 'updatedBy' => 40, 'password' => 'Tcity@123', 'firstname' => $row['author_name'], 'token' => $row['author_password']);
         //print_r($attributes);
         $user = new User();
         $user->detachBehavior('user');
         $user->detachBehavior('ip');
         $user->setAttributes($attributes);
         $user->setPassword($attributes['password']);
         $user->generateAuthKey();
         $user->Id = $attributes['Id'];
         if ($user->save(false)) {
             echo "User " . $attributes['username'] . ": imported\n";
         } else {
             echo "User " . $attributes['username'] . ": not imported\n";
         }
     }
 }
開發者ID:rajanishtimes,項目名稱:partnerapi,代碼行數:21,代碼來源:ImportController.php

示例3: loadAttributes

 /**
  * Loads attributes to the user model. You should override this method if you are going to add new fields to the
  * registration form. You can read more in special guide.
  *
  * By default this method set all attributes of this model to the attributes of User model, so you should properly
  * configure safe attributes of your User model.
  *
  * @param User $user
  */
 protected function loadAttributes(\common\models\User $user)
 {
     $user->setAttributes($this->attributes);
     $user->generatePasswordResetToken();
     $user->is_provider = 0;
     $user->registered_by();
     $user->generateInviteHash();
     $user->generatePhoneVerificationHash();
     $user->generateRoleCode();
     $user->created_at = time();
     $user->updated_at = time();
     $user->status = 20;
 }
開發者ID:bokko79,項目名稱:servicemapp,代碼行數:22,代碼來源:RegistrationUserForm.php


注:本文中的common\models\User::setAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。