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?


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Laravel 仓库 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01