本文整理汇总了PHP中app\models\Users::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getId方法的具体用法?PHP Users::getId怎么用?PHP Users::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAuthenticate
public function actionAuthenticate()
{
$request = Yii::$app->request;
$username = $request->post('username');
$user = Users::findByUsername($username);
// Just create the user if not found
if (!$user) {
$user = new Users();
$user->username = $username;
$user->save();
}
echo json_encode(['auth' => $user->getId() ? true : false, 'id' => $user->id, 'username' => $user->username]);
}
示例2: test_finds
public function test_finds()
{
$user = new Users();
$user->username = 'yurii';
$user->password = 'pass';
$user->access_token = 'token';
$user->save();
$user2 = new Users();
$user2->username = 'yurii2';
$user2->password = 'pass2';
$user2->access_token = 'token2';
$user2->save();
$this->assertEquals($user->username, $user->getId());
$this->assertEquals($user->username, Users::findIdentity($user->username)->username);
$this->assertEquals($user->username, Users::getUserByUsername($user->username)->username);
$this->assertEquals($user->access_token, Users::findIdentityByAccessToken($user->access_token)->access_token);
}
示例3: update
/**
* @param Users $user
* @return bool
*/
public function update(Users $user)
{
if ($user->getId() == 1 && session('user')->getId() != 1) {
return false;
}
return $user->update();
}