Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 1.4/1中每个登录的唯一令牌Id_Php_Mysql_Doctrine_Symfony 1.4 - Fatal编程技术网

Php Symfony 1.4/1中每个登录的唯一令牌Id

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

我使用的是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 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);
}