2016-02-16 05:39
浏览 40

symfony2 php访问另一个实体的对象

I know its very lame question to ask. I have One Entity ContentSelector and another is Content in Content Selector I have a property Content where I have Id. I am trying to access the Content propety but always getting error. This is what I am trying to do.

$cs = $pages->getContentSelector();

it returns:


    "id": ​22,
    "title": "my Title",
    "content": "11021,10930,10874,10766,10954,10705,10948,10934,11048,11049,10831"


now I want to get the content property like $cs->content getting error like:

"Notice: Undefined property: Doctrine\\ORM\\PersistentCollection::$content"

tried with getContent(); getting error that the method doesnt exist. but in ContentSelector the method actually exists.

how can I easily get the content ids?

图片转代码服务由CSDN问答提供 功能建议

我知道这是一个非常蹩脚的问题。 我有一个实体ContentSelector,另一个是内容选择器中的内容我有一个属性内容,我有Id。 我正在尝试访问Content propety但总是收到错误。 这就是我想要做的。

  $ cs = $ pages-> getContentSelector(); 
 <  p>它返回: 
“title”:“my title”,
“content”  :“11021,10930,10874,10766,10954,10705,10948,10934,11048,11049,10831”

现在 我想得到像 $ cs-&gt; content 这样的内容属性,如:

 “注意:未定义的属性:Doctrine \\ ORM \  \ PersistentCollection :: $ content“

尝试使用getContent(); 得到该方法不存在的错误。 但在ContentSelector中,该方法实际存在。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题