2010-05-19 84 views
1

我的应用程序使用sfGuardUser插件。我的一个表与sf_guard_user表有关系,因此在基本模型中有一个对应的setSfGuardUser()函数。从Actions.class.php,我试图设置当前用户使用这个函数,(然后我保存在数据库中)的对象。
我尝试:使用setSfGuardUser()将当前用户保存在模型中

->setSfGuardUser($this->getUser()); //called from inside Actions.class.php 

,这将引发一个错误:

Couldn't call Doctrine_Core::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references. 

...# at Doctrine_Record->coreSetRelated('sfGuardUser', object('myUser')) 

这让我觉得的getUser()未返回sfGuardUser对象,虽然我不知道如何检查。谁能提供任何见解?

+0

顺便说一句,就是我目前做的是: - > setSfGuardUser(学说:: getTable( 'sfGuardUser') - > findOneByUsername($这个 - >的getUser() - > getUsername())); 这似乎有点不必要 – LTME 2010-05-19 23:18:01

回答

2

$this->getUser()返回myUser实例。你需要$this->getUser()->getGuardUser()

相关问题