当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::find方法代码示例

本文整理汇总了PHP中app\models\Users::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::find方法的具体用法?PHP Users::find怎么用?PHP Users::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Users的用法示例。


在下文中一共展示了Users::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 public function actionIndex()
 {
     $this->View->title = 'Mi cuenta';
     $modelAccount = new FormAccount();
     $contact = Users::find()->one(Gbox::$components->user->id);
     $modelAccount->firstname = $contact->firstname;
     $modelAccount->lastname = $contact->lastname;
     $modelAccount->email = $contact->email;
     $modelAccount->username = $contact->username;
     if (Gbox::getRequest()->isPost() && $modelAccount->load(Gbox::getRequest()->post())) {
         if (!empty($modelAccount->password) && $modelAccount->password != $modelAccount->password_confirm) {
             $modelAccount->addError('password_confirm', 'La contraseña debe coincidir con la confirmación.');
         }
         if ($modelAccount->validate()) {
             $table = new Users();
             $table->firstname = $modelAccount->firstname;
             $table->lastname = $modelAccount->lastname;
             $table->email = $modelAccount->email;
             if (!empty($modelAccount->password) && $modelAccount->password == $modelAccount->password_confirm) {
                 $table->password = crypt($modelAccount->password, '$2y$10$' . Gbox::getConfig()->params['salt']);
             }
             if ($table->update(Gbox::$components->user->id)) {
                 $msg = 'Se ha editado su cuenta con éxito.';
                 Session::set('response', ['msg' => $msg, 'type' => 'success']);
             } else {
                 Session::set('response', ['msg' => 'Ha ocurrido un error al editar su cuenta.', 'type' => 'danger']);
             }
         } else {
             Session::set('response', ['msg' => 'Ocurrió un error, revise los campos y vuelva a intentarlo.', 'type' => 'warning']);
         }
     }
     return $this->render('index', ['modelAccount' => $modelAccount]);
 }
开发者ID:roxgueldevs,项目名称:gboxframework,代码行数:33,代码来源:AccountController.php

示例2: findByUsername

 /**
  * Finds user by username
  *
  * @param  string      $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $dbUser = DbUser::find()->where(["usr_id" => $username, "usr_active" => 1])->one();
     if (!count($dbUser)) {
         return null;
     }
     // 	self::$users[100]=['id'=>100,'usr_id' => $dbUser->usr_id, 'usr_name' => $dbUser->usr_name];
     //     	self::$users= [
     //          '100' => [
     //              'id' => '100',
     //              'usr_id' => 'Admin',
     //              'usr_pass' => 'Admin',
     //              'authKey' => 'test100key',
     //              'accessToken' => '100-token',
     //          ]];
     // 	die(var_dump(self::$users));
     //     	foreach (self::$users as $user) {
     //     		if (strcasecmp($user['usr_id'], $username) === 0) {
     //     			return new static($user);
     //     		}
     //     	}
     //     	return null;
     return new static($dbUser);
     //     	         foreach (self::$users as $user) {
     //     		             if (strcasecmp($user['usr_id'], $username) === 0) {
     //     		                 return new static($user);
     //     		             }
     //     	         }
 }
开发者ID:AtaBashir,项目名称:ams,代码行数:35,代码来源:User.php

示例3: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Users::find()->where(['UserName' => $this->username, 'Password' => md5($this->password)])->one();
     }
     return $this->_user;
 }
开发者ID:raguila,项目名称:islc,代码行数:12,代码来源:LoginForm.php

示例4: actionIndex

 public function actionIndex($message = 'message')
 {
     $query = Users::find();
     $pagination = new Pagination(['defaultPageSize' => 2, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('username')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['countries' => $countries, 'pagination' => $pagination, 'message' => $message]);
 }
开发者ID:k1llforl1ve,项目名称:students,代码行数:7,代码来源:UsersController.php

示例5: usuario_existe

 public function usuario_existe($attribute, $params)
 {
     $table = Users::find()->where("nombre_usuario=:nom", [":nom" => $this->nombre_usuario]);
     if ($table->count() != 0) {
         $this->addError($attribute, "El nobre de usuario seleccionado existe");
     }
 }
开发者ID:emiherber,项目名称:sgdcae,代码行数:7,代码来源:ValidarProfesor.php

示例6: checkEmailExists

 public function checkEmailExists($attr)
 {
     $user = Users::find()->where('email', $this->{$attr})->one();
     if ($user) {
         $this->addError($attr, 'El correo ya se encuentra registrado. Intente iniciar sesión o utilice otro.');
     }
 }
开发者ID:roxgueldevs,项目名称:gboxframework,代码行数:7,代码来源:FormAccountSignUp.php

示例7: edit

 public function edit($user_id)
 {
     $user = Users::find($user_id);
     $data = ['title' => 'Edit User ' . $user->name, 'user' => $user, 'save_url' => route('root-users-save', ['user_id' => $user->id])];
     $this->title->prepend($data['title']);
     View::share('menu_item_active', 'users');
     return view('root.users.user', $data);
 }
开发者ID:vitos8686,项目名称:0ez,代码行数:8,代码来源:UsersController.php

示例8: findByUsername

 /**
  * Finds user by username
  *
  * @param  string      $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $dbUser = DbUser::find()->where(["username" => $username])->one();
     if (!count($dbUser)) {
         return null;
     }
     return new static($dbUser);
 }
开发者ID:zogodo,项目名称:weibin,代码行数:14,代码来源:User.php

示例9: actionIndex

 public function actionIndex()
 {
     $users = Users::find()->all();
     /*echo "<pre>";
       print_r( $users );
       die();*/
     return $this->render('index', ['users' => $users]);
 }
开发者ID:kolyan131313,项目名称:yiigit,代码行数:8,代码来源:UsersController.php

示例10: findById

 public static function findById($id)
 {
     $user = Users::find()->where(array('id' => $id))->asArray()->one();
     if ($user) {
         return new static($user);
     }
     return null;
 }
开发者ID:PichurChill,项目名称:sues_print,代码行数:8,代码来源:User.php

示例11: delete

 public function delete()
 {
     if (!$this->request->is('post') && !$this->request->is('delete')) {
         $msg = "Users::delete can only be called with http:post or http:delete.";
         throw new DispatchException($msg);
     }
     Users::find($this->request->data['id'])->delete();
     return $this->redirect('Users::index');
 }
开发者ID:nilamdoc,项目名称:li3_example,代码行数:9,代码来源:UsersController.php

示例12: usuario_existe

 public function usuario_existe($attribute, $params)
 {
     $table = Users::find()->where(['nombre_usuario' => $this->nombre_usuario]);
     if ($table->count() != 0) {
         $this->addError($attribute, "El nobre de usuario seleccionado existe");
         return true;
     }
     return false;
 }
开发者ID:lucho314,项目名称:cae,代码行数:9,代码来源:ValidarRegistro.php

示例13: getAll

 public static function getAll()
 {
     $query = Users::find()->orderBy('id desc');
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $pages->defaultPageSize = 27;
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     return ['models' => $models, 'pages' => $pages];
 }
开发者ID:huynt57,项目名称:bluebee-ng,代码行数:9,代码来源:Users.php

示例14: username_existe

 public function username_existe($attribute, $params)
 {
     //Buscar el username en la tabla
     $table = Users::find()->where("username=:username", [":username" => $this->username]);
     //Si el username existe mostrar el error
     if ($table->count() == 1) {
         $this->addError($attribute, "El usuario seleccionado existe");
     }
 }
开发者ID:raulinho,项目名称:yii,代码行数:9,代码来源:FormRegister.php

示例15: getUser

 protected function getUser($id, &$user)
 {
     $user = null;
     $success = false;
     if ($id > 0) {
         $success = ($user = Users::find($id)) ? true : false;
     }
     return $success;
 }
开发者ID:romainwurtz,项目名称:Li3Press,代码行数:9,代码来源:UsersController.php


注:本文中的app\models\Users::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。