2
我使用Symfony 1.4,Doctrine 1.2和sfDoctrineGuardPlugin。在我的actions.class.php有:如何正确获取ID?
$this->idsfguard = $this->getUser()->getGuardUser()->getId();
,如果我在这工作好我登录,但如果然后我退出,我有错误:
Fatal error: Call to a member function getId() on a non-object in
我想:
if ($this->getUser()->getGuardUser()->isAuthenticated()){
$this->idsfguard = $this->getUser()->getGuardUser()->getId();
}
但我有错误:
Fatal error: Call to a member function isAuthenticated() on a non-object in
谢谢!现在在模板成功我应该使用isset($ id)相同在清除php?在symfony做不同? –
@Beded Black:isset()很好。只要确保将变量作为“$ this-> id”传递给模板,然后可以执行isset($ id)。 – Tom