How to catch an id from sfUser?(如何从 sfUser 中获取 id?)
问题描述
我正在使用 symfony 1.4 &我使用 sfDoctrineGuardPlugin 作为身份验证工具.
I'm working with symfony 1.4 & i use sfDoctrineGuardPlugin as a tool for authentifications.
我想获取用户的 ID 以便将其存储在我的表中.
I want to catch the Id of user in order te store it in my table.
经过一个小的研究,我想我必须使用那个表达式:getUser()->getGuardUser()->getId()
.
After a small research, I guess I have to use that expression : getUser()->getGuardUser()->getId()
.
我正在寻找的是如何为我的目标投资该表达.
What i looking for is how to invest that expression for my target.
推荐答案
如果用户通过了身份验证,是的,你可以使用:
if the user is authenticated, yes, you can use:
// inside an action
$id = $this->getUser()->getGuardUser()->getId();
// inside a template
$id = $sf_user->getGuardUser()->getId();
如果用户未通过身份验证,则会抛出错误.
If the user is not authenticated, it'll throw an error.
这篇关于如何从 sfUser 中获取 id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 sfUser 中获取 id?


基础教程推荐
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01