Php Symfony 1.4/1中每个登录的唯一令牌Id
我使用的是Symfony 1.4的旧版本 我使用SFGuardToctrine插件来实现基本的安全性 我想再次检查,这将做我想做的,也如果有更好的方式来完成我正在做的事情Php Symfony 1.4/1中每个登录的唯一令牌Id,php,mysql,doctrine,symfony-1.4,Php,Mysql,Doctrine,Symfony 1.4,我使用的是Symfony 1.4的旧版本 我使用SFGuardToctrine插件来实现基本的安全性 我想再次检查,这将做我想做的,也如果有更好的方式来完成我正在做的事情 // make sure that the key is not in the database on signin do { // generate new keys $key = $this->generateRandomKey(); // make sure random key
// make sure that the key is not in the database on signin
do {
// generate new keys
$key = $this->generateRandomKey();
// make sure random key is not used
$key_check = Doctrine::getTable('sfGuardUserProfile')->checkDuplicateKey($key);
} while (count($key_check) < 1);
获取令牌Id的条令查询
static public function checkDuplicateKey($key)
{
return Doctrine_Query::create()
->select('u.token_id')
->from('sfGuardUserProfile u')
->where('u.token_id = ?')
->fetchOne(array($key), Doctrine::HYDRATE_ARRAY);
}
此代码在用户登录时执行。
我的问题是
1) 它会为每个用户提供唯一的id吗?2)有没有更好的方法来完成这项任务
先谢谢你
static public function checkDuplicateKey($key)
{
return Doctrine_Query::create()
->select('u.token_id')
->from('sfGuardUserProfile u')
->where('u.token_id = ?')
->fetchOne(array($key), Doctrine::HYDRATE_ARRAY);
}