本文整理汇总了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]);
}
示例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);
// }
// }
}
示例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;
}
示例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]);
}
示例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");
}
}
示例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.');
}
}
示例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);
}
示例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);
}
示例9: actionIndex
public function actionIndex()
{
$users = Users::find()->all();
/*echo "<pre>";
print_r( $users );
die();*/
return $this->render('index', ['users' => $users]);
}
示例10: findById
public static function findById($id)
{
$user = Users::find()->where(array('id' => $id))->asArray()->one();
if ($user) {
return new static($user);
}
return null;
}
示例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');
}
示例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;
}
示例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];
}
示例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");
}
}
示例15: getUser
protected function getUser($id, &$user)
{
$user = null;
$success = false;
if ($id > 0) {
$success = ($user = Users::find($id)) ? true : false;
}
return $success;
}