本文整理匯總了PHP中sfGuardUserPeer::doCount方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfGuardUserPeer::doCount方法的具體用法?PHP sfGuardUserPeer::doCount怎麽用?PHP sfGuardUserPeer::doCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfGuardUserPeer
的用法示例。
在下文中一共展示了sfGuardUserPeer::doCount方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeSignin
/**
* This is a symfony workaround. As soon as someone logs in check if they are in the DB.
* If they aren't just insert them so they can authenticate.
*
* @param sfWebRequest $request
*/
public function executeSignin($request)
{
if ($request->isMethod("post")) {
$form = new sfGuardFormSignin();
$username = $request->getParameter($form->getName() . "[username]");
$c = new Criteria();
$c->add(sfGuardUserPeer::USERNAME, $username);
$res = sfGuardUserPeer::doCount($c);
// if they dont exist in the db then stick them in so LDAP works
if ($res == 0) {
$u = new sfGuardUser();
$u->setUsername($username);
$u->save();
$u->getProfile();
}
}
parent::executeSignin($request);
}
示例2: countUsers
public static function countUsers()
{
$cache = sfcontext::getInstance()->getViewCacheManager() ? sfcontext::getInstance()->getViewCacheManager()->getCache() : false;
if ($cache) {
$key = md5("users_counter");
$data = unserialize($cache->get($key));
} else {
$data = false;
}
if (!$data) {
//$user = sfContext::getInstance()->getUser();
//$culture = $user->getCulture();
$cuser = new Criteria();
$cuser->add(sfGuardUserPeer::IS_ACTIVE, 1);
$data = sfGuardUserPeer::doCount($cuser);
if ($cache) {
$cache->set($key, serialize($data), 360);
}
}
return $data;
}