protected function createTokenId()
    {
        $max = strlen($this->tokenChars) - 1;
        $len = strlen($this->tokenFormat);

        do {
            $out = '';
            for ($i = 0; $i < $len; $i++) {
                if ('\\' == $this->tokenFormat[$i]) {
                    $i++;
                    $out .= $this->tokenFormat[$i];
                } else {
                    $out .= $this->tokenChars[mt_rand(0, $max)];
                }
            }

        } while ($this->db->fetchOne('SELECT gto_id_token FROM gems__tokens WHERE gto_id_token = ?', $out));

        return $out;
    }
protected function createTokenId()
    {
        $max = strlen($this->tokenChars) - 1;
        $len = strlen($this->tokenFormat);

        do {
            $out = '';
            for ($i = 0; $i < $len; $i++) {
                if ('\\' == $this->tokenFormat[$i]) {
                    $i++;
                    $out .= $this->tokenFormat[$i];
                } else {
                    $out .= $this->tokenChars[mt_rand(0, $max)];
                }
            }

        } while ($this->db->fetchOne('SELECT gto_id_token FROM gems__tokens WHERE gto_id_token = ?', $out));

        return $out;
    }
protected function createTokenId ( ) { $ max = strlen ( $ this -> tokenChars ) - 1 ; $ len = strlen ( $ this -> tokenFormat ) ; do { $ out = '' ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( '\\' == $ this -> tokenFormat [ $ i ] ) { $ i ++ ; $ out .= $ this -> tokenFormat [ $ i ] ; } else { $ out .= $ this -> tokenChars [ mt_rand ( 0 , $ max ) ] ; } } } while ( $ this -> db -> fetchOne ( 'SELECT gto_id_token FROM gems__tokens WHERE gto_id_token = ?' , $ out ) ) ; return $ out ; }
Generates a random token and checks for uniqueness

@return string A non-existing token
Generates a random token and checks for uniqueness