0

我正在尝试让“产品”页面显示特定用户的简介和图片。我拥有的代码在下面,但它不断拉动当前登录的用户的简介和图片,这不是我想要的。一旦我注销,我就会收到Call to a member function getBlurb() on a non-object错误消息。有没有办法调出特定用户的“模糊”和“图片”字段?

public function executeShow(sfWebRequest $request)
  {
    $this->car = $this->getRoute()->getObject();
    $seller_id = $this->car->getSeller_id();
    $this->seller = $this->getUser()->getGuardUser($seller_id);
    $this->blurb = $this->seller->getBlurb();
    $this->picture = $this->seller->getPicture();
  }
4

1 回答 1

0

$this->seller不是对象,因为$this->getUser()->getGuardUser($seller_id);不接受任何参数,它只检索当前用户。在 中查看该方法定义sfGuardSecurityUser

你必须这样做:

教义:$this->seller = $this->car->getSeller();

推进:$this->seller = SfGuardUserPeer::retrieveByPK($seller_id);

于 2012-11-03T10:49:46.657 回答