本文整理汇总了PHP中UserQuery::findByRedditID方法的典型用法代码示例。如果您正苦于以下问题:PHP UserQuery::findByRedditID方法的具体用法?PHP UserQuery::findByRedditID怎么用?PHP UserQuery::findByRedditID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserQuery
的用法示例。
在下文中一共展示了UserQuery::findByRedditID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUser
protected function setUser($reddit_id, $name)
{
$query = new UserQuery();
$users = $query->findByRedditID($reddit_id);
$user = null;
if ($users->count() == 0) {
$user = new User();
$user->setUsername($name);
$user->setRedditID($reddit_id);
$user->save();
} else {
$user = $users->getFirst();
}
$_SESSION[Auth::$SESSION_USER_ID] = $user->getId();
}
示例2: setUser
protected function setUser($reddit_id, $name)
{
$query = new UserQuery();
$users = $query->findByRedditID($reddit_id);
$user = null;
if ($users->count() == 0) {
$user = new User();
$user->setUsername($name);
$user->setRedditID($reddit_id);
$user->save();
} else {
$user = $users->getFirst();
}
if ($user->getBanned()) {
// We block banned users by just not letting them log in
session_destroy();
return null;
} else {
$_SESSION[Auth::$SESSION_USER_ID] = $user->getId();
//Record login
UserAccess::addUserEvent($user, $_SERVER['REMOTE_ADDR'], UserAccessType::login);
return $user;
}
}